-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from piwheels/241-project-page
New project page layout and JSON API
- Loading branch information
Showing
21 changed files
with
1,062 additions
and
483 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
UPDATE configuration SET version = '0.19'; | ||
|
||
DROP FUNCTION get_project_versions(TEXT); | ||
CREATE FUNCTION get_project_versions(pkg TEXT) | ||
RETURNS TABLE( | ||
version versions.version%TYPE, | ||
yanked BOOLEAN, | ||
released TIMESTAMP WITH TIME ZONE, | ||
skip versions.skip%TYPE, | ||
builds_succeeded TEXT, | ||
builds_failed TEXT | ||
) | ||
LANGUAGE SQL | ||
RETURNS NULL ON NULL INPUT | ||
SECURITY DEFINER | ||
SET search_path = public, pg_temp | ||
AS $sql$ | ||
SELECT | ||
v.version, | ||
v.yanked, | ||
v.released AT TIME ZONE 'UTC', | ||
COALESCE(NULLIF(v.skip, ''), p.skip) AS skip_msg, | ||
COALESCE(STRING_AGG(DISTINCT b.abi_tag, ',') FILTER (WHERE b.status), '') AS builds_succeeded, | ||
COALESCE(STRING_AGG(DISTINCT b.abi_tag, ',') FILTER (WHERE NOT b.status), '') AS builds_failed | ||
FROM | ||
packages p | ||
JOIN versions v USING (package) | ||
LEFT JOIN builds b USING (package, version) | ||
WHERE v.package = pkg | ||
GROUP BY version, skip_msg, released, yanked; | ||
$sql$; | ||
|
||
REVOKE ALL ON FUNCTION get_project_versions(TEXT) FROM PUBLIC; | ||
GRANT EXECUTE ON FUNCTION get_project_versions(TEXT) TO {username}; | ||
|
||
DROP FUNCTION get_file_apt_dependencies(fn TEXT); | ||
CREATE FUNCTION get_file_apt_dependencies(fn VARCHAR) | ||
RETURNS TABLE( | ||
dependency dependencies.dependency%TYPE | ||
) | ||
LANGUAGE SQL | ||
RETURNS NULL ON NULL INPUT | ||
SECURITY DEFINER | ||
SET search_path = public, pg_temp | ||
AS $sql$ | ||
SELECT dependency | ||
FROM dependencies | ||
WHERE filename = fn | ||
AND tool = 'apt' | ||
EXCEPT ALL | ||
SELECT apt_package | ||
FROM preinstalled_apt_packages p | ||
JOIN files f | ||
ON p.abi_tag = f.abi_tag | ||
WHERE f.filename = fn; | ||
$sql$; | ||
|
||
REVOKE ALL ON FUNCTION get_file_apt_dependencies(VARCHAR) FROM PUBLIC; | ||
GRANT EXECUTE ON FUNCTION get_file_apt_dependencies(VARCHAR) TO {username}; | ||
|
||
DROP FUNCTION get_project_files(TEXT); | ||
CREATE FUNCTION get_project_files(pkg TEXT) | ||
RETURNS TABLE( | ||
version builds.version%TYPE, | ||
platform_tag files.platform_tag%TYPE, | ||
builder_abi builds.abi_tag%TYPE, | ||
file_abi_tag files.abi_tag%TYPE, | ||
filename files.filename%TYPE, | ||
filesize files.filesize%TYPE, | ||
filehash files.filehash%TYPE, | ||
yanked versions.yanked%TYPE, | ||
dependencies VARCHAR ARRAY | ||
) | ||
LANGUAGE SQL | ||
RETURNS NULL ON NULL INPUT | ||
SECURITY DEFINER | ||
SET search_path = public, pg_temp | ||
AS $sql$ | ||
SELECT | ||
b.version, | ||
f.platform_tag, | ||
b.abi_tag AS builder_abi, | ||
f.abi_tag AS file_abi_tag, | ||
f.filename, | ||
f.filesize, | ||
f.filehash, | ||
v.yanked, | ||
ARRAY_AGG(d.dependency) | ||
FILTER (WHERE d.dependency IS NOT NULL) AS dependencies | ||
FROM | ||
builds b | ||
JOIN files f USING (build_id) | ||
JOIN versions v USING (package, version) | ||
LEFT JOIN LATERAL ( | ||
SELECT f.filename, d.dependency | ||
FROM get_file_apt_dependencies(f.filename) AS d | ||
) d USING (filename) | ||
WHERE b.status | ||
AND b.package = pkg | ||
GROUP BY ( | ||
version, platform_tag, builder_abi, file_abi_tag, filename, filesize, | ||
filehash, yanked | ||
); | ||
$sql$; | ||
|
||
REVOKE ALL ON FUNCTION get_project_files(TEXT) FROM PUBLIC; | ||
GRANT EXECUTE ON FUNCTION get_project_files(TEXT) TO {username}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.