Fix the new package-versions-for-branch query
This recent change simply didn't work, the ordering was bad and the window function wasn't properly defined. It now should hopefully work, although there's an interesting case where different versions are available for different systems/targets, which isn't handled particularly well.
This commit is contained in:
parent
5081a64c1f
commit
a50bc3342f
1 changed files with 14 additions and 8 deletions
|
|
@ -237,7 +237,9 @@ SELECT DISTINCT
|
||||||
last_value(last_guix_revision_commit) OVER version_window AS last_guix_revision_commit,
|
last_value(last_guix_revision_commit) OVER version_window AS last_guix_revision_commit,
|
||||||
last_value(last_datetime) OVER version_window AS last_datetime
|
last_value(last_datetime) OVER version_window AS last_datetime
|
||||||
FROM (
|
FROM (
|
||||||
SELECT package_version,
|
SELECT DISTINCT -- Because of systems and targets, maybe they should
|
||||||
|
-- be parameters?
|
||||||
|
package_version,
|
||||||
first_guix_revisions.commit AS first_guix_revision_commit,
|
first_guix_revisions.commit AS first_guix_revision_commit,
|
||||||
first_git_branches.datetime AS first_datetime,
|
first_git_branches.datetime AS first_datetime,
|
||||||
last_guix_revisions.commit AS last_guix_revision_commit,
|
last_guix_revisions.commit AS last_guix_revision_commit,
|
||||||
|
|
@ -246,22 +248,26 @@ FROM (
|
||||||
INNER JOIN guix_revisions AS first_guix_revisions
|
INNER JOIN guix_revisions AS first_guix_revisions
|
||||||
ON first_guix_revision_id = first_guix_revisions.id
|
ON first_guix_revision_id = first_guix_revisions.id
|
||||||
INNER JOIN git_branches AS first_git_branches
|
INNER JOIN git_branches AS first_git_branches
|
||||||
ON first_guix_revisions.git_repository_id = first_git_branches.git_repository_id
|
ON package_derivations_by_guix_revision_range.branch_name = first_git_branches.name
|
||||||
|
AND first_guix_revisions.git_repository_id = first_git_branches.git_repository_id
|
||||||
AND first_guix_revisions.commit = first_git_branches.commit
|
AND first_guix_revisions.commit = first_git_branches.commit
|
||||||
INNER JOIN guix_revisions AS last_guix_revisions
|
INNER JOIN guix_revisions AS last_guix_revisions
|
||||||
ON last_guix_revision_id = last_guix_revisions.id
|
ON last_guix_revision_id = last_guix_revisions.id
|
||||||
INNER JOIN git_branches AS last_git_branches
|
INNER JOIN git_branches AS last_git_branches
|
||||||
ON last_guix_revisions.git_repository_id = last_git_branches.git_repository_id
|
ON package_derivations_by_guix_revision_range.branch_name = last_git_branches.name
|
||||||
|
AND last_guix_revisions.git_repository_id = last_git_branches.git_repository_id
|
||||||
AND last_guix_revisions.commit = last_git_branches.commit
|
AND last_guix_revisions.commit = last_git_branches.commit
|
||||||
WHERE package_name = $1
|
WHERE package_name = $1
|
||||||
AND package_derivations_by_guix_revision_range.git_repository_id = $2
|
AND package_derivations_by_guix_revision_range.git_repository_id = $2
|
||||||
AND package_derivations_by_guix_revision_range.branch_name = $3
|
AND package_derivations_by_guix_revision_range.branch_name = $3
|
||||||
AND first_git_branches.name = $3
|
ORDER BY package_version DESC, first_git_branches.datetime ASC
|
||||||
AND last_git_branches.name = $3
|
|
||||||
ORDER BY first_datetime ASC, package_version DESC
|
|
||||||
) AS data1
|
) AS data1
|
||||||
WINDOW version_window AS (PARTITION BY package_version)
|
WINDOW version_window AS (
|
||||||
ORDER BY first_datetime DESC, package_version DESC"
|
PARTITION BY data1.package_version
|
||||||
|
ORDER BY data1.package_version DESC, data1.first_datetime ASC
|
||||||
|
RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||||
|
)
|
||||||
|
ORDER BY package_version DESC, first_datetime ASC"
|
||||||
(list package-name
|
(list package-name
|
||||||
(number->string git-repository-id)
|
(number->string git-repository-id)
|
||||||
branch-name)))
|
branch-name)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue