Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend finalize_new_version to resolve advisory duplicates #1513

Merged
merged 1 commit into from Nov 15, 2019

Conversation

goosemania
Copy link
Member

@goosemania goosemania commented Nov 13, 2019

Also move createrepo_c object generation for advisory to corresponding
models. Add ability to generate createrpeo_c object with additional
collecitons.

closes #4295
https://pulp.plan.io/issues/4295

@pep8speaks
Copy link

pep8speaks commented Nov 13, 2019

Hello @goosemania! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-11-15 21:40:16 UTC

@goosemania goosemania changed the title Advisory merge Extend finalize_new_version to resolve advisory duplicates Nov 14, 2019
@@ -528,8 +580,7 @@ class UpdateCollection(Model):
shortname = models.TextField()
module = models.TextField(default='')

update_record = models.ForeignKey(UpdateRecord, related_name="collections",
on_delete=models.CASCADE)
update_record = models.ManyToManyField(UpdateRecord, related_name="collections")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed not to duplicate collections when we merge advisories.

Migrations are squashed due to this change.

@goosemania goosemania force-pushed the story4295 branch 3 times, most recently from 4fceace to 19dd96a Compare November 15, 2019 11:54
CHANGES/4295.feature Outdated Show resolved Hide resolved
previous_advisory = previous_advisories.get(
rpm_updaterecord__id=advisory_id).rpm_updaterecord
added_advisory = version.content.get(
rpm_updaterecord__id=advisory_id, pk__in=added_advisory_pks).rpm_updaterecord
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you convert previous_advisories to UpdateRecords:

previous_advisories = UpdateRecord.filter(pk__in=previous_version.content.filter(pulp_type='rpm.advisory'))

You could simplify these lines:

previous_advisory = previous_advisories.get(id=advisory_id)
added_advisory = version.content.get(id=advisory_id, pk__in=added_advisory_pks)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, does this not work?

added_advisory = version.content.get(id=advisory_id, pk__in=added_advisories)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daviddavis, I'll try.
Well, maybe it's the right thing to do everything with the same approach, so I'll probably convert to use UpdateRecord, similar to how you use Modulemd. I just want travis to pass, and then I cam refactor. Testing of correct merging takes some time as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, does this not work?

added_advisory = version.content.get(id=advisory_id, pk__in=added_advisories)

This doesn't work because content is the master model, so it will be rpm_updaterecord__id=advisory_id but the main problem is in added_advisories.
I get django.db.utils.ProgrammingError: subquery has too many columns (either by using version.content or UpdateRecord). It's all because added_advisories is a result of qs.difference. So I'm back to collecting pks.

if previous_version:
previous_advisories = previous_version.content.filter(pulp_type='rpm.advisory')
previous_advisory_ids = set(previous_advisories.values_list('rpm_updaterecord__id',
flat=True))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you convert previous_advisories to UpdateRecords (see my other comment), you can simplify this:

previous_advisory_ids = set(previous_advisories.values_list('id', flat=True))

Also move createrepo_c object generation for advisory to corresponding
models. Add ability to generate createrpeo_c object with additional
collecitons.

closes #4295
https://pulp.plan.io/issues/4295
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants