Page MenuHomePhabricator

Tool list editing and display has unexpected/non-deterministic ordering for tools in list
Closed, ResolvedPublicBUG REPORT

Description

Our toolhub.apps.lists.models.ToolList model uses a ManyToManyField with a through relation to store and retrieve the tools associated with a list. The through relation is handled by the toolhub.apps.lists.models.ToolListItem model which adds "order", "added_by", and "added_date" attributes to the M2M relation between a ToolList and a Tool.

The bug is that the "order" field on ToolListItem is not used by the DRF view layer when it outputs a list. Playing with manual Django object queries, it seems that if the toollistitem_set reverse manager is used to query for the tools in a list then the ToolListItem default ordering is used (what we want), but if the tools manager is used then ordering is left up to the db engine.

Event Timeline

The existing behavior is functional (meaning that lists can be created, edited, and viewed), but confusing. The confusion it gets worse when doing certain edits and then looking at the diffs. This is actually how the issue came to our attention as @Slst2020 was working on adding a UI for viewing list edit diffs.

Change 755518 had a related patch set uploaded (by Raymond Ndibe; author: Raymond Ndibe):

[wikimedia/toolhub@main] lists: order tools in toollist

https://gerrit.wikimedia.org/r/755518

Raymond_Ndibe moved this task from In Progress to Review on the Toolhub board.
Raymond_Ndibe moved this task from Backlog to In Review on the User-Raymond_Ndibe board.

Change 755518 merged by jenkins-bot:

[wikimedia/toolhub@main] lists: order tools in toollist

https://gerrit.wikimedia.org/r/755518

Change 770638 had a related patch set uploaded (by BryanDavis; author: Bryan Davis):

[operations/deployment-charts@master] toolhub: Bump container version to 2022-03-15-002555-production

https://gerrit.wikimedia.org/r/770638

Change 770638 merged by jenkins-bot:

[operations/deployment-charts@master] toolhub: Bump container version to 2022-03-15-002555-production

https://gerrit.wikimedia.org/r/770638