Skip to content

BE 2 - Implement filter_multiple_columns API function #31

@notjackl3

Description

@notjackl3

Create an API function to filter volunteers by multiple column with configurable logical operations. Here are some resources:

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.

Metadata

Metadata

Assignees

Labels

backendthis ticket is part of the backend

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions