freedomofpress / pressfreedomtracker.us

Code for the U.S. Press Freedom Tracker project website
https://pressfreedomtracker.us
GNU Affero General Public License v3.0
18 stars 7 forks source link

Tag management #746

Closed harrislapiroff closed 4 years ago

harrislapiroff commented 5 years ago

Currently we have a number of tags that have no incidents associated with them. These clutter up tag lists and provide no filtering benefit since they will always yield zero incidents when filtered with. I would like to propose two mitigations for this:

chigby commented 4 years ago

Having looked into it a little bit, I'm coming to the conclusion that this issue might need further specification.

Specifically the first item, which I'm not sure is possible without (fairly significant?) changes to the official wagtail-autocomplete plugin. When we had our own ad-hoc autocomplete API it might have been possible to create distinct filtering logic between different models. If there is a way to "hook" into this via the wagtail-autocomplete, I was not able to find it, and the docs seem to imply there is not one.

It may be possible to accomplish the same thing by writing a custom TagManager that overrides the default queryset to exclude tags having a zero incident count. But I'm not sure that this is quite the thing we want, and this solution possibly too intrusive. I'd also want to this out/experiment with it a little bit, as I'm not sure about how the interaction between using the autocomplete input to create a tag, which begins with zero incidents, would interact with subsequent searching for it prior to the incident being saved.

What do you think about all this? Am I missing something here?

Writing a management command to prune orphan tags still seems reasonable to me.

harrislapiroff commented 4 years ago

Ah, yes, that would require the long-awaited resolution to https://github.com/wagtail/wagtail-autocomplete/issues/36. Hmph. Okay, well just the management command for now sounds fine.

chigby commented 4 years ago

I have thrown together a small consolation prize, which is not asked for in this issue, but I think will improve the visibility of our overall tag situation.