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

Remove old flagrequest when manually unflagging #140

Open
jelly opened this issue Sep 17, 2018 · 7 comments
Open

Remove old flagrequest when manually unflagging #140

jelly opened this issue Sep 17, 2018 · 7 comments

Comments

@jelly
Copy link
Member

jelly commented Sep 17, 2018

When manually unflagging the old flagrequest is not removed while it should be.

Number of flag requests can be obtained by:

>>> from packages.models import FlagRequest
>>> FlagRequest.objects.count()

Steps:

  • Check the number of flagged packages
  • Flag a package
  • Unflag the same package
  • Number of flagged packages should be the same.
@jelly
Copy link
Member Author

jelly commented Sep 25, 2018

Queries for removing old flagrequests in postgresql

Listing old flagrequests

SELECT fr.id,fr.created,fr.pkgbase,fr.pkgver,fr.pkgrel,fr.epoch FROM packages_flagrequest as fr INNER JOIN packages as ps ON (fr.pkgbase = ps.pkgbase AND fr.pkgver != ps.pkgver AND fr.repo_id = ps.repo_id) ORDER BY fr.created desc;

Deleting old flagrequests

DELETE FROM packages_flagrequest as fr USING packages as ps WHERE fr.pkgbase = ps.pkgbase AND fr.pkgver != ps.pkgver AND fr.repo_id = ps.repo_id;

@jelly
Copy link
Member Author

jelly commented Sep 25, 2018

Missing are the packages of with the pkgbase does not exists anymore in the repos.

@jelly
Copy link
Member Author

jelly commented Sep 25, 2018

Remove packages. This isn't handled by our code yet.

select id,pkgbase from packages_flagrequest as fr where not exists (select * from packages where fr.pkgbase = packages.pkgbase)

@jelly
Copy link
Member Author

jelly commented Sep 30, 2018

Correct query to fetch to be removed packages.

select fr.id, fr.pkgbase, fr.created, fr.pkgver from packages_flagrequest fr left outer join packages p on p.pkgbase = fr.pkgbase and p.repo_id = fr.repo_id and p.flag_date is not null where p.pkgbase is null;

@jelly
Copy link
Member Author

jelly commented Mar 3, 2019

One case, unflag for $pkg can be simply fixed by the following code in def unflag(req, ...):

     FlagRequest.objects.filter(pkgbase=pkg.pkgbase,
                                repo__name__iexact=repo,
                                pkgver=pkg.pkgver,
                                epoch=pkg.epoch).delete()

But it will also remove a FlagRequest when it's a split package which should not be done. So the code still has to check if it's a split package and only remove it when it's the last split package left.

@jelly
Copy link
Member Author

jelly commented Mar 17, 2019

Also it seems that [testing] => [core] moves are not handled and aren't removed as well.

@jelly
Copy link
Member Author

jelly commented Mar 19, 2019

Commit 7d162a0 should handle deletions of packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant