Community Health: Obsolete resources and corresponding entities#3965
Community Health: Obsolete resources and corresponding entities#3965functionzz wants to merge 15 commits intomozilla:mainfrom
Conversation
mathjazz
left a comment
There was a problem hiding this comment.
Nice work!
Please also make sure that everywhere in the code where we references all resources (and count on the fact that obsolete resources are currently not present), we now reference active resources only.
mathjazz
left a comment
There was a problem hiding this comment.
Thanks for the update!
This will need extensive testing before we ship it.
8ee6402 to
92481ce
Compare
|
I guess the next natural step is writing tests for the various cases listed here if everything looks fine. |
That would be great! |
|
@eemeli, I would like some guidance on how to test these |
eemeli
left a comment
There was a problem hiding this comment.
Looks good; see inline for some relatively minor things.
I would like some guidance on how to test these
.current()properties. Since all previous tests pass. I'm finding it difficult to come up with tests without just testing how.current()works over and over again.
Eh, What's here is already pretty decent. I would like to see something exercising TranslatedResource.objects.current() after ResourceQuerySet.mark_as_obsolete() is called, but that's about it.
|
I'll leave this open in case @mathjazz wants to take another look at it once he's back, but I think this is good to merge. |
|
The patch is deployed to the dev instance: We should also test it with sync. |
|
Tried throwing an LLM at this, might be worth checking?
@property
def translated_resources(self):
trs = TranslatedResource.objects # ← should be .current()
if self.project is not None:
trs = trs.filter(resource__project=self.project)
if self.locale is not None:
trs = trs.filter(locale=self.locale)
return trs
changed_resources: dict[int, Resource] | None = (
{res.pk: res for res in project.resources.filter(path__in=updates.keys())}
if updates
else None
)What happens if a string was previously marked as obsolete, but comes back?
# entities.py:293 (add_resources)
ordered_resources = project.resources.order_by("path")
# project.py:310 (reset_resource_order)
for idx, r in enumerate(self.resources.order_by("path")):Should we exclude obsolete resources here, even if practically it doesn't matter? |
|
Possibly a few more. Are these counting obsolete resources? |
|
Applied the first two changes.
If it comes back, it should come back as a new string, not an un-obsoleted version of the old string.
Let's not add
Yes, these are, although they should not be, as these refer to |
Does not delete resources/entities/translated_resources - filters for obsolete strings will be added later
Co-authored-by: Matjaž Horvat <matjaz.horvat@gmail.com>
Co-authored-by: Eemeli Aro <eemeli@gmail.com>
Co-authored-by: Eemeli Aro <eemeli@gmail.com>
5bcbbf3 to
f87d13d
Compare
Summary
This PR addresses the data loss incurred when someone removes strings from projects like Firefox. Instead of obsoleting the strings, we currently delete the data which causes contributior attribution to be lost.
Fixes #2133.