Excessive calls to Tag.reset_filter_count in Tag.remove_filter_taggings

Description

Tag.remove_filter_taggings contains too many calls to Tag.reset_filter_count – one for each FilterTagging that gets deleted. Since each call to reset_filter_count forces the database to count all visible works in the filter (which requires a join between two tables, and conditions on both), I believe this results in runtime quadratic in the number of works in the tag. It would be better to keep it linear, and only call reset_filter_count once per filter.

This is more of a runtime change than a functionality change, but to verify that the pull request hasn't completely stripped out the ability to fix the filter counts when wrangling, I believe this test will work:

1. Pick two small fandom tags, one canonical, one non-canonical.
2. Count the number of works in both tags.
3. Syn the non-canonical fandom to the canonical fandom.
4. Verify that when you view the canonical fandom on the Fandoms page, the number listed beside the fandom has changed. (You may have to wait a few minutes.)
5. De-syn the non-canonical fandom.
6. Verify that when you view the canonical fandom on the Fandoms page, the number listed beside the fandom has gone back down. (You may have to wait a few minutes.)

(And of course, and mean you might have to try a few times to get wrangling to stick.)

Environment

None

Status

Assignee

ticking instant

Reporter

ticking instant

Roadmap

Tag Wrangling

Priority

Medium

Affects versions

0.9.202

Fix versions

Components

BackEnd

Difficulty

Medium

Required Access Level

Tag Wrangler

Milestone

Internal 0.9
Configure