Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework API filtering logic #486

Open
rhigman opened this issue Mar 16, 2023 · 2 comments
Open

Rework API filtering logic #486

rhigman opened this issue Mar 16, 2023 · 2 comments
Assignees
Labels
enhancement Improvement request

Comments

@rhigman
Copy link
Member

rhigman commented Mar 16, 2023

          Overall, rather than `TimeExpression` I'm more inclined to support filtering by field more widely. Something like:
pub enum Operator {
    Eq,
    Neq,
    Gt,
    Lt,
    Gte,
    Lte,
    Ilike,
}

pub struct WorkFilter {
    pub field: WorkField,
    pub operator: Operator,
    pub value: String,
}

fn works (
        [...]
        filters: Vec<WorkFilter>,
        [...]
)

Originally posted by @ja573 in #484 (review)

To do:

  • replace filter, filter_param_1, filter_param_2 and filter_param_3 in Crud::all() and Crud::count() with a single filters param, as above
  • move existing field-specific filter logic from crud.rs modules into graphql/model.rs, continuing to expose most of the existing field-specific filter params to the user for compatibility/ease of use
  • treat all expressions that share the same field as OR statements
@rhigman
Copy link
Member Author

rhigman commented Jun 14, 2023

OR statements

The existing filter logic creates two kinds of OR statements:

  1. Same field, multiple values [same operator]: e.g. filter_param_1 might be used to check for works whose workType equals monograph OR edited_book (this case was covered in the original design above)
  2. Same value, multiple fields [same operator]: e.g. filter might be used to check for works whose title OR abstract contains keyword

@rhigman
Copy link
Member Author

rhigman commented Aug 9, 2023

In progress at https://github.com/thoth-pub/thoth/tree/feature/486_rework_filtering. Basic proof of concept achieved for statement type 2 above. Design work still needed on how to also handle type 1. Currently on hold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement request
Projects
None yet
Development

No branches or pull requests

1 participant