feat(#590): add "Testing Version" column to todo lists#675
Conversation
c632ea0 to
970c545
Compare
christian-heusel
left a comment
There was a problem hiding this comment.
Thanks a lot for working on this! 🤗 🚀 I have two small questions and will defer to the project maintainers for the overall verdict! 😄
| # now build a lookup dict to attach to the correct package | ||
| lookup = {(p.pkgname, p.arch): p for p in testing_pkgs} | ||
|
|
||
| annotated = [] |
There was a problem hiding this comment.
This seems to be unused, why is it there? 🤔
I see that it's also part of the logic in attach_staging(), but maybe you have some context of it now that you worked on attach_testing().
There was a problem hiding this comment.
ah true. I only "copied" the behavior of "attach_staging". I think it is a leftover, I will remove it 👍
There was a problem hiding this comment.
the "real magic" happens with the lookup dict regarding performance and in the loop afterwards the data is "attached" (the versions of the packages)
| def attach_testing(packages, list_id): | ||
| '''Look for any testing version of the packages provided and attach them | ||
| to the 'testing' attribute on each package if found.''' | ||
| pkgnames = TodolistPackage.objects.filter( | ||
| todolist_id=list_id).values('pkgname') | ||
| testing_pkgs = Package.objects.normal().filter(repo__testing=True, | ||
| pkgname__in=pkgnames) | ||
| # now build a lookup dict to attach to the correct package | ||
| lookup = {(p.pkgname, p.arch): p for p in testing_pkgs} | ||
|
|
||
| annotated = [] | ||
| for package in packages: | ||
| in_testing = lookup.get((package.pkgname, package.arch), None) | ||
| package.testing = in_testing | ||
|
|
||
| return annotated |
There was a problem hiding this comment.
Would it be an option to refactor attach_staging() to use a parameter to keep the overall code more DRY?
There was a problem hiding this comment.
I think yes, I'll update the PR shortly
…ude new fixtures for todolist dev(archlinux#590): add missing fixtures for todo lists cleanup ci/cd: fix ruff address-review: refactor for cleaner code
970c545 to
d3d022d
Compare
This PR adds the column "Testing Version" to /todos/:a_list containing the version of the package in the Testing Repo, if present.
Additionally, fixtures and tests are added.
Closes #590