Skip to content

Fix filtering epics when sorting by dates

Jarka Košanová requested to merge 230827-fix-epics-filter into master

What does this MR do?

This MR fixes searching epics when they are sorted by start date or due date. A specific case when the search does not work is when all words in the search string have less than 3 characters.

The problem is that due date and start date (start_date, end_date columns) are not in simple_sorts attributes for epics.

Screenshots

Before the change

Screenshot_2020-09-21_at_17.02.32

After the change

Screenshot_2020-09-21_at_17.01.56

SQL queries

Before the change (example from the issue used)

SELECT "epics".* FROM "epics" WHERE "epics"."group_id" IN (WITH RECURSIVE "base_and_descendants" AS ((SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND "namespaces"."id" = 6543)
UNION
(SELECT "namespaces".* FROM "namespaces", "base_and_descendants" WHERE "namespaces"."type" = 'Group' AND "namespaces"."parent_id" = "base_and_descendants"."id")) SELECT "namespaces"."id" FROM "base_and_descendants" AS "namespaces") AND "epics"."state_id" = 1 AND ("epics"."title" ILIKE 'fy 21 q3' OR "epics"."description" ILIKE 'fy 21 q3') ORDER BY end_date ASC NULLS LAST, id DESC, "epics"."id" DESC

Query plan: https://explain.depesz.com/s/CJLE

After the change

WITH "epics" AS ((SELECT "epics".* FROM "epics" WHERE "epics"."group_id" IN (WITH RECURSIVE "base_and_descendants" AS ((SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND "namespaces"."id" = 6543)
UNION
(SELECT "namespaces".* FROM "namespaces", "base_and_descendants" WHERE "namespaces"."type" = 'Group' AND "namespaces"."parent_id" = "base_and_descendants"."id")) SELECT "namespaces"."id" FROM "base_and_descendants" AS "namespaces") AND "epics"."state_id" = 1)) SELECT "epics".* FROM epics WHERE ("epics"."title" ILIKE '%fy 21 q3%' OR "epics"."description" ILIKE '%fy 21 q3%') ORDER BY end_date ASC NULLS LAST, id DESC, "epics"."id" DESC

Query plan: https://explain.depesz.com/s/9pfa

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Issue #230827 (closed)

Edited by Zeger-Jan van de Weg

Merge request reports