wellcomecollection / content-api

📖 The API + ETL pipeline for searching the Wellcome Collection Prismic Repository.
MIT License
0 stars 0 forks source link

add filter/aggs to events endpoint #102

Closed agnesgaroux closed 7 months ago

agnesgaroux commented 7 months ago

What does this change?

https://github.com/wellcomecollection/content-api/issues/71 Adds filters and aggregations to /events search endpoint

How to test

Stage https://api-stage.wellcomecollection.org/content/v0/events?aggregations=format%2Caudience%2CisOnline%2Cinterpretation

Filtered by interpretation=Auto-captioned and format=Discussion https://api-stage.wellcomecollection.org/content/v0/events?aggregations=format%2Caudience%2CisOnline%2Cinterpretation&interpretation=X2jPiRMAACIA8Vzo&format=Wd-QYCcAACcAoiJS&pageSize=1

How can we measure success?

Ability to filter event searches

Have we considered potential risks?

Still behind a toggle

agnesgaroux commented 7 months ago

As per MVP definition, excluding isChildScheduledEvent: true from search

agnesgaroux commented 7 months ago

Response for /events?aggregations=format%2Caudience%2CisOnline%2Cinterpretation&interpretation=X2jPiRMAACIA8Vzo&format=Wd-QYCcAACcAoiJS&pageSize=1

{
  "type": "ResultList",
  "results": [
    {
      "type": "Event",
      "id": "YnpPVxAAACIAI9Fp",
      "title": "Reconsidering the Vagina",
      "image": {
        "type": "PrismicImage",
        "dimensions": {
          "width": 4000,
          "height": 2250
        },
        "alt": "Photograph of a tablet standing on a table showing Wellcome Collection's website on the screen. The web page shows the text \"A free museum and library exploring health and human experience\". A hand holding a mug of tea is next to the tablet.",
        "copyright": "Online event | Photo: Kathleen Arundell | Wellcome Collection | | CC-BY-NC | |",
        "url": "https://images.prismic.io/wellcomecollection/b3636974-fa44-4746-8535-78b022209637_EP_001508_0005+16x9+Kathleen+Arundell.jpg?auto=compress,format",
        "id": "YnJdvRAAACMAkk9e",
        "edit": {
          "x": 0,
          "y": 0,
          "zoom": 1,
          "background": "#fff"
        },
        "32:15": {
          "dimensions": {
            "width": 3200,
            "height": 1500
          },
          "alt": "Photograph of a tablet standing on a table showing Wellcome Collection's website on the screen. The web page shows the text \"A free museum and library exploring health and human experience\". A hand holding a mug of tea is next to the tablet.",
          "copyright": "Online event | Photo: Kathleen Arundell | Wellcome Collection | | CC-BY-NC | |",
          "url": "https://images.prismic.io/wellcomecollection/b3636974-fa44-4746-8535-78b022209637_EP_001508_0005+16x9+Kathleen+Arundell.jpg?auto=compress,format&rect=0,188,4000,1875&w=3200&h=1500",
          "id": "YnJdvRAAACMAkk9e",
          "edit": {
            "x": 0,
            "y": -150,
            "zoom": 0.8,
            "background": "#fff"
          }
        },
        "16:9": {
          "dimensions": {
            "width": 3200,
            "height": 1800
          },
          "alt": "Photograph of a tablet standing on a table showing Wellcome Collection's website on the screen. The web page shows the text \"A free museum and library exploring health and human experience\". A hand holding a mug of tea is next to the tablet.",
          "copyright": "Online event | Photo: Kathleen Arundell | Wellcome Collection | | CC-BY-NC | |",
          "url": "https://images.prismic.io/wellcomecollection/b3636974-fa44-4746-8535-78b022209637_EP_001508_0005+16x9+Kathleen+Arundell.jpg?auto=compress,format&rect=0,0,4000,2250&w=3200&h=1800",
          "id": "YnJdvRAAACMAkk9e",
          "edit": {
            "x": 0,
            "y": 0,
            "zoom": 0.8,
            "background": "#fff"
          }
        },
        "square": {
          "dimensions": {
            "width": 3200,
            "height": 3200
          },
          "alt": "Photograph of a tablet standing on a table showing Wellcome Collection's website on the screen. The web page shows the text \"A free museum and library exploring health and human experience\". A hand holding a mug of tea is next to the tablet.",
          "copyright": "Online event | Photo: Kathleen Arundell | Wellcome Collection | | CC-BY-NC | |",
          "url": "https://images.prismic.io/wellcomecollection/b3636974-fa44-4746-8535-78b022209637_EP_001508_0005+16x9+Kathleen+Arundell.jpg?auto=compress,format&rect=875,0,2250,2250&w=3200&h=3200",
          "id": "YnJdvRAAACMAkk9e",
          "edit": {
            "x": -1244,
            "y": 0,
            "zoom": 1.4222222222222223,
            "background": "#fff"
          }
        }
      },
      "times": [
        {
          "startDateTime": "2022-05-24T15:00:00.000Z",
          "endDateTime": "2022-05-24T16:00:00.000Z",
          "isFullyBooked": {
            "inVenue": false,
            "online": false
          }
        }
      ],
      "format": {
        "type": "EventFormat",
        "id": "Wd-QYCcAACcAoiJS",
        "label": "Discussion"
      },
      "locations": [
        {
          "type": "EventLocation",
          "id": "ef04c8e3-26be-4fbc-9bef-f52589ebc56c",
          "label": "Online"
        }
      ],
      "interpretations": [
        {
          "type": "EventInterpretation",
          "id": "X2jPiRMAACIA8Vzo",
          "label": "Auto-captioned"
        }
      ],
      "audiences": [],
      "series": [
        {
          "id": "WoK-NioAACkANeWK",
          "title": "Library Insights",
          "contributors": []
        }
      ]
    }
  ],
  "aggregations": {
    "audience": {
      "buckets": [
        {
          "data": {
            "type": "EventAudience",
            "id": "WlYWECQAACcAWdBf",
            "label": "Youth event"
          },
          "count": 1,
          "type": "AggregationBucket"
        }
      ],
      "type": "Aggregation"
    },
    "interpretation": {
      "buckets": [
        {
          "data": {
            "type": "EventInterpretation",
            "id": "X2jPiRMAACIA8Vzo",
            "label": "Auto-captioned"
          },
          "count": 27,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "WmXl4iQAACUAnyDr",
            "label": "Speech-to-text"
          },
          "count": 18,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "X2smLBMAACMA-99Z",
            "label": "British Sign Language"
          },
          "count": 14,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "WmXhziQAACQAnw7i",
            "label": "Audio described"
          },
          "count": 11,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "Wn3STCoAACgAIedR",
            "label": "Hearing loop"
          },
          "count": 11,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "X2jPZRMAACEA8VxE",
            "label": "Audio described"
          },
          "count": 10,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "YqiCnxEAACMA8VLW",
            "label": "Speech-to-text"
          },
          "count": 10,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "W5JXVSYAACYAGtkh",
            "label": "Relaxed"
          },
          "count": 9,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "XkFGqxEAACIAIhNH",
            "label": "British Sign Language"
          },
          "count": 9,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "YzGD9hEAAEAKfx0E",
            "label": "Captioned (online)"
          },
          "count": 6,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "X2jP2RMAACIA8V5b",
            "label": "Auto-captioned"
          },
          "count": 5,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "XdVIsREAAHH-IrHi",
            "label": "Captioned"
          },
          "count": 2,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "Xz1FCBAAACgAHJ56",
            "label": "Captioned"
          },
          "count": 2,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "YEEDDhAAACUAMRKu",
            "label": "Speech-to-text"
          },
          "count": 2,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "YjnF1BEAACIAeEBy",
            "label": "Speech-to-text"
          },
          "count": 1,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventInterpretation",
            "id": "ZW751RIAACUAvsjx",
            "label": "British Sign Language"
          },
          "count": 1,
          "type": "AggregationBucket"
        }
      ],
      "type": "Aggregation"
    },
    "format": {
      "buckets": [
        {
          "data": {
            "type": "EventFormat",
            "id": "Wd-QYCcAACcAoiJS",
            "label": "Discussion"
          },
          "count": 27,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventFormat",
            "id": "W5fV0iYAACYAMxF9",
            "label": "Screening"
          },
          "count": 6,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventFormat",
            "id": "WcKmiysAACx_A8NR",
            "label": "Workshop"
          },
          "count": 4,
          "type": "AggregationBucket"
        },
        {
          "data": {
            "type": "EventFormat",
            "id": "dfc2b7f9-c362-47da-9644-b0f98212ccaa",
            "label": "Event"
          },
          "count": 3,
          "type": "AggregationBucket"
        }
      ],
      "type": "Aggregation"
    },
    "isOnline": {
      "buckets": [
        {
          "data": {
            "type": "EventLocation",
            "isOnline": true
          },
          "count": 27,
          "type": "AggregationBucket"
        }
      ],
      "type": "Aggregation"
    }
  },
  "pageSize": 1,
  "totalPages": 27,
  "totalResults": 27,
  "nextPage": "https://api.wellcomecollection.org/content/v0/events?aggregations=format%2Caudience%2CisOnline%2Cinterpretation&interpretation=X2jPiRMAACIA8Vzo&format=Wd-QYCcAACcAoiJS&pageSize=1&page=2"
}