001-view_public_events.sql 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. CREATE OR REPLACE VIEW view_public_events AS
  2. SELECT
  3. b.uuid,
  4. b.organization_id AS organizationId,
  5. b.name,
  6. b.description,
  7. b.url,
  8. b.datetimeStart,
  9. b.datetimeEnd,
  10. b.gender_id as gender,
  11. COALESCE(b.priceMini, 0) AS priceMini,
  12. COALESCE(b.priceMaxi, 0) AS priceMaxi,
  13. null as categoryCode,
  14. p.name AS placeName,
  15. p.description AS placeDescription,
  16. p.floorSize AS placeFloorSize,
  17. p.capacity AS placeCapacity,
  18. ap.addressCity AS city,
  19. ap.postalCode,
  20. TRIM(BOTH ' ' FROM CONCAT( IFNULL(ap.streetAddress, ''), ' ', IFNULL(ap.streetAddressSecond, ''), ' ', IFNULL(ap.streetAddressThird, ''))) AS streetAddress,
  21. ap.longitude,
  22. ap.latitude,
  23. r.name AS roomName,
  24. r.description AS roomDescription,
  25. r.localisation AS roomLocalisation,
  26. r.capacity AS roomCapacity,
  27. r.floorSize AS roomFloorSize,
  28. IF(b.image_id is not null, CONCAT('https://api.opentalent.fr/api/public/files/', b.image_id, '/download/lg'), null) AS imageUrl,
  29. IF(b.image_id is not null, CONCAT('https://api.opentalent.fr/api/public/files/', b.image_id, '/download/md'), null) AS thumbnailUrl,
  30. (SELECT GROUP_CONCAT(DISTINCT CONCAT(f.code))
  31. FROM event_categories AS ec
  32. LEFT JOIN Categories AS cs ON(cs.id = ec.categories_id)
  33. LEFT JOIN Familly AS f ON(f.id = cs.familly_id)
  34. WHERE ec.event_id = b.id
  35. ) AS categories,
  36. 'opentalent' as origin,
  37. b.image_id as imgId,
  38. b.id as entityId
  39. FROM Booking AS b
  40. INNER JOIN Organization o ON o.id = b.organization_id
  41. INNER JOIN Parameters par ON par.id = o.parameters_id
  42. LEFT JOIN Place AS p ON (p.id = b.place_id)
  43. LEFT JOIN AddressPostal AS ap ON (ap.id = p.addressPostal_id)
  44. LEFT JOIN Room AS r ON (r.id = b.room_id)
  45. WHERE b.discr = 'event'
  46. AND b.datetimeEnd >= NOW()
  47. AND b.visibility = 'PUBLIC_VISIBILITY'
  48. AND b.isCanceled = 0
  49. AND b.gender_id <> 7
  50. UNION
  51. SELECT
  52. aw.uuid,
  53. null AS organizationId,
  54. aw.name,
  55. aw.description,
  56. aw.deepLink AS url,
  57. aw.datetimeStart,
  58. aw.datetimeEnd,
  59. NULL as gender,
  60. aw.priceMini,
  61. aw.priceMaxi,
  62. aw.subCategory AS categoryCode,
  63. aw.place AS placeName,
  64. NULL AS placeDescription,
  65. NULL AS placeFloorSize,
  66. NULL AS placeCapacity,
  67. aw.city,
  68. aw.postalCode,
  69. aw.streetAddress,
  70. aw.longitude,
  71. aw.latitude,
  72. NULL AS roomName,
  73. NULL AS roomDescription,
  74. NULL AS roomLocalisation,
  75. NULL AS roomCapacity,
  76. NULL AS roomFloorSize,
  77. aw.largeimage AS imageUrl,
  78. aw.mediumimage as thumbnailUrl,
  79. aw.categoryCode AS categories,
  80. 'awin' as origin,
  81. NULL as imgId,
  82. aw.id as entityId
  83. FROM AwinProduct as aw
  84. WHERE
  85. aw.datetimeEnd >= NOW()
  86. AND aw.datetimeStart IS NOT NULL;