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

Does the incident filterset OR or AND its arguments? #354

Closed
hmpf opened this issue Mar 3, 2022 · 1 comment
Closed

Does the incident filterset OR or AND its arguments? #354

hmpf opened this issue Mar 3, 2022 · 1 comment
Assignees

Comments

@hmpf
Copy link
Contributor

hmpf commented Mar 3, 2022

We need to verify what the filterset does when given more than one flag: OR or AND. We want AND most of the time.

Originally posted by @hmpf in #206 (comment)

@hmpf hmpf self-assigned this Mar 3, 2022
@hmpf hmpf changed the title Does the incident filterset oR or AND its arguments? Does the incident filterset OR or AND its arguments? Mar 3, 2022
@hmpf
Copy link
Contributor Author

hmpf commented Mar 7, 2022

django_filters.filterset.filter_queryset() runs the filters in a loop.

/api/v2/incidents/?acked=true&stateful=true wind up callingl queryset.acked().stateful(). This is equivalent to

'SELECT "argus_incident_incident"."id", "argus_incident_incident"."start_time",
"argus_incident_incident"."end_time","argus_incident_incident"."source_id", 
"argus_incident_incident"."source_incident_id", "argus_incident_incident"."details_url", 
"argus_incident_incident"."description", "argus_incident_incident"."level",
"argus_incident_incident"."ticket_url" FROM "argus_incident_incident" 
WHERE (
  "argus_incident_incident"."id" IN (
    SELECT DISTINCT U1."incident_id" FROM "argus_incident_acknowledgement" U0 
      INNER JOIN "argus_incident_event" U1 ON (U0."event_id" = U1."id"
    ) WHERE NOT (U0."expiration" <= 2022-03-07 11:33:15.190594+00:00 AND U0."expiration" IS NOT NULL)
  )
  AND "argus_incident_incident"."end_time" IS NOT NULL
)
ORDER BY "argus_incident_incident"."start_time" DESC'

So: filterset works with AND.

@hmpf hmpf closed this as completed Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant