Fix filtering epics when sorting by dates
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
After the change
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
-
Changelog entry - [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
Issue #230827 (closed)
Edited by Zeger-Jan van de Weg