Explorar el Código

Merge branch 'fix/categorie-fnac' into 'develop'

event fnac filters

See merge request opentalent/ap2i!68
Maha Bouchiba hace 1 año
padre
commit
9b0681df0f
Se han modificado 2 ficheros con 101 adiciones y 24 borrados
  1. 71 23
      sql/schema-extensions/001-view_public_events.sql
  2. 30 1
      src/Entity/Public/PublicEvent.php

+ 71 - 23
sql/schema-extensions/001-view_public_events.sql

@@ -1,34 +1,82 @@
 CREATE OR REPLACE VIEW view_public_events
 AS
     SELECT
-        b.uuid, b.organization_id AS organizationId, b.name, b.description, b.url, b.datetimeStart, b.datetimeEnd, null as price_mini, null as price_maxi,
-        p.name AS placeName, p.description AS placeDescription, p.floorSize AS placeFloorSize, p.capacity AS placeCapacity,
-        ap.addressCity AS city, ap.postalCode,
-        TRIM(BOTH ' ' FROM CONCAT( if(ap.streetAddress is null,'',ap.streetAddress), ' ', if(ap.streetAddressSecond is null,'',ap.streetAddressSecond), ' ', if(ap.streetAddressThird is null,'',ap.streetAddressThird))) AS streetAddress,
-        ap.longitude, ap.latitude,
-        r.name AS roomName, r.description AS roomDescription, r.localisation AS roomLocalisation, r.capacity AS roomCapacity, r.floorSize AS roomFloorSize,
-        If(b.image_id is not null, CONCAT('https://api.opentalent.fr/app.php/_internal/secure/files/', b.image_id, '/raw'), null) AS imageUrl,
-        If(b.image_id is not null, CONCAT('https://api.opentalent.fr/app.php/_internal/secure/files/', b.image_id, '/0x120'), null) AS thumbnailUrl,
-        (SELECT GROUP_CONCAT(CONCAT(f.code))
+        b.uuid, 
+        b.organization_id AS organizationId, 
+        b.name, 
+        b.description, 
+        b.url, 
+        b.datetimeStart, 
+        b.datetimeEnd, 
+        null as price_mini, 
+        null as price_maxi, 
+        null as categoryCode,
+        p.name AS placeName, 
+        p.description AS placeDescription, 
+        p.floorSize AS placeFloorSize, 
+        p.capacity AS placeCapacity,
+        ap.addressCity AS city, 
+        ap.postalCode,
+        TRIM(BOTH ' ' FROM CONCAT( IFNULL(ap.streetAddress, ''), ' ', IFNULL(ap.streetAddressSecond, ''), ' ', IFNULL(ap.streetAddressThird, ''))) AS streetAddress,
+        ap.longitude, 
+        ap.latitude,
+        r.name AS roomName, 
+        r.description AS roomDescription, 
+        r.localisation AS roomLocalisation, 
+        r.capacity AS roomCapacity, 
+        r.floorSize AS roomFloorSize,
+        IF(b.image_id is not null, CONCAT('https://api.opentalent.fr/app.php/_internal/secure/files/', b.image_id, '/raw'), null) AS imageUrl,
+        IF(b.image_id is not null, CONCAT('https://api.opentalent.fr/app.php/_internal/secure/files/', b.image_id, '/0x120'), null) AS thumbnailUrl,
+        (SELECT GROUP_CONCAT(DISTINCT CONCAT(f.code))
          FROM event_categories AS ec
             LEFT JOIN Categories AS cs ON(cs.id = ec.categories_id)
             LEFT JOIN Familly AS f ON(f.id = cs.familly_id)
          WHERE ec.event_id = b.id
-        ) AS categories, 'opentalent' as origin, b.id as entityId
+        ) AS categories, 
+        'opentalent' as origin, 
+        b.id as entityId
     FROM Booking AS b
-             INNER JOIN Organization o ON o.id = b.organization_id
-             INNER JOIN Parameters par ON par.id = o.parameters_id
-             LEFT JOIN Place AS p ON (p.id = b.place_id)
-             LEFT JOIN AddressPostal AS ap ON (ap.id = p.addressPostal_id)
-             LEFT JOIN Room AS r ON (r.id = b.room_id)
-    WHERE b.discr = 'event' AND b.datetimeEnd >= NOW() AND b.visibility = 'PUBLIC_VISIBILITY' AND b.isCanceled = 0
+        INNER JOIN Organization o ON o.id = b.organization_id
+        INNER JOIN Parameters par ON par.id = o.parameters_id
+        LEFT JOIN Place AS p ON (p.id = b.place_id)
+        LEFT JOIN AddressPostal AS ap ON (ap.id = p.addressPostal_id)
+        LEFT JOIN Room AS r ON (r.id = b.room_id)
+    WHERE b.discr = 'event' 
+        AND b.datetimeEnd >= NOW() 
+        AND b.visibility = 'PUBLIC_VISIBILITY' 
+        AND b.isCanceled = 0
 UNION
     SELECT
-        aw.uuid, null AS organizationId, aw.name, aw.description, aw.deepLink AS url, aw.datetimeStart, aw.datetimeEnd, aw.price_mini, aw.price_maxi,
-        aw.place AS placeName, NULL AS placeDescription, NULL AS placeFloorSize, NULL AS placeCapacity,
-        aw.city, aw.postalCode, aw.streetAddress, aw.longitude, aw.latitude,
-        NULL AS roomName, NULL AS roomDescription, NULL AS roomLocalisation, NULL AS roomCapacity, NULL AS roomFloorSize,
-        aw.largeimage AS imageUrl, aw.mediumimage as thumbnailUrl, aw.categories AS categories, 'awin' as origin, aw.id as entityId
-    FROM  AwinProduct as aw
+        aw.uuid, 
+        null AS organizationId, 
+        aw.name, 
+        aw.description, 
+        aw.deepLink AS url, 
+        aw.datetimeStart, 
+        aw.datetimeEnd, 
+        aw.price_mini, 
+        aw.price_maxi, 
+        aw.categoryCode,
+        aw.place AS placeName, 
+        NULL AS placeDescription, 
+        NULL AS placeFloorSize, 
+        NULL AS placeCapacity,
+        aw.city, 
+        aw.postalCode, 
+        aw.streetAddress, 
+        aw.longitude, 
+        aw.latitude,
+        NULL AS roomName, 
+        NULL AS roomDescription, 
+        NULL AS roomLocalisation, 
+        NULL AS roomCapacity, 
+        NULL AS roomFloorSize,
+        aw.largeimage AS imageUrl, 
+        aw.mediumimage as thumbnailUrl, 
+        aw.categories AS categories, 
+        'awin' as origin, 
+        aw.id as entityId
+    FROM AwinProduct as aw
     WHERE
-        aw.datetimeEnd >= NOW() AND aw.datetimeStart IS NOT NULL;
+        aw.datetimeEnd >= NOW() 
+        AND aw.datetimeStart IS NOT NULL;

+ 30 - 1
src/Entity/Public/PublicEvent.php

@@ -9,6 +9,7 @@ use ApiPlatform\Metadata\ApiResource;
 use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
 use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
 use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
+use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
 use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
 use ApiPlatform\Metadata\ApiFilter;
 use App\Filter\ApiPlatform\Utils\DistanceFilter;
@@ -38,6 +39,10 @@ use Doctrine\ORM\Mapping as ORM;
 #[ApiFilter(filterClass: DateFilter::class, properties: ['datetimeStart', 'datetimeEnd'])]
 #[ApiFilter(filterClass: DistanceFilter::class)]
 #[ApiFilter(filterClass: OrderFilter::class, properties: ['datetimeStart', 'datetimeEnd'], arguments: ['orderParameterName' => 'order'])]
+#[ApiFilter(filterClass: SearchFilter::class, properties: ['origin' => 'exact'])]
+#[ApiFilter(filterClass: RangeFilter::class, properties: ['price_mini', 'price_maxi'])]
+#[ApiFilter(filterClass: SearchFilter::class, properties: ['categoryCode' => 'exact'])]
+
 class PublicEvent
 {
     #[ORM\Id]
@@ -104,6 +109,7 @@ class PublicEvent
 
     #[ORM\Column]
     private string $origin = 'opentalent';
+
     #[ORM\Column(type: 'integer')]
     private int $entityId;
 
@@ -113,6 +119,10 @@ class PublicEvent
     #[ORM\Column]
     private int $price_maxi;
 
+    // categoryCode 
+    #[ORM\Column]
+    private ?string $categoryCode;
+
     /**
      * @return string
      */
@@ -544,4 +554,23 @@ class PublicEvent
         $this->price_maxi = $price_maxi;
         return $this;
     }
-}
+
+    /**
+     * @return string|null
+     */
+    public function getCategoryCode(): ?string
+    {
+        return $this->categoryCode;
+    }
+
+    /**
+     * @param string|null $categoryCode
+     * @return PublicEvent
+     */
+    public function setCategoryCode(?string $categoryCode): PublicEvent
+    {
+        $this->categoryCode = $categoryCode;
+        return $this;
+    }
+    
+}