-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Create an API function to filter volunteers by multiple column with configurable logical operations. Here are some resources:
- Our Supabase dashboard's documentation on how to work with Volunteers table
- Our Supabase Volunteer table schema.
- Our Supabase dashboard's documentation on how to work with VolunteersRoles table
- Our Supabase VolunteerRoles table schema.
- Our Supabase dashboard's documentation on how to work with Roles table
- Our Supabase Roles table schema.
- Our Supabase dashboard's documentation on how to work with VolunteersCohorts table
- Our Supabase VolunteerCohorts table schema.
- Our Supabase dashboard's documentation on how to work with Cohorts table
- Our Supabase Cohorts table schema.
- Our database schema which helps you visualize how the tables are connected
Params:
-
<filters_list>: An array of tuples (<mini_op>, <field>, <values>), representing the multiple filters that the user wants to apply at once. Here is the breakdown of the each property:
- <mini_op>: string - Operation to perform (AND [must match all values], OR [must match at least one value]). This will determine how the values in a column filter are combined
- <field>: string - Field to filter for (e.g Roles, Cohorts, name_org, email, etc.)
- <values>: stringList - Values from the same column to filter for (e.g. f2f, front_desk). -
< op>: string - Either "OR" or "AND" representing how the filters should be combined, by matching all ("AND") or matching any ("OR") of the filters.
Notes:
- You may assume the implementation and use other API functions (filter_by_cohort, filter_by_role, and filter_general), if you find it convenient.
- Note that roles and cohorts are not columns in the Volunteers table; they are tables themselves (Cohorts and Roles).
- The function shall return the filtered row(s)
- The API functions should be written inside src/lib/api/
- Ensure proper error handling and validation of input data
- If you need to install any dependency, write about it on your PR.
The goal is to:
- Create a GET endpoint that accepts a filters list of many values from the same column with a specific logical operation defined, and returns filtered volunteer(s) from Supabase
- Return appropriate success/error responses with HTTP status codes.