Files
woodpecker/store/datastore/sql/postgres/files/feed.sql
6543 3af5f99fb2 Fix repo access (#476) (#477)
Backport #476

* fix repo access

* fix permission syncing

Co-authored-by: Anbraten <anton@ju60.de>
2021-10-26 23:27:05 +02:00

62 lines
1.2 KiB
SQL

-- name: feed-latest-build
SELECT
repo_owner
,repo_name
,repo_full_name
,build_number
,build_event
,build_status
,build_created
,build_started
,build_finished
,build_commit
,build_branch
,build_ref
,build_refspec
,build_remote
,build_title
,build_message
,build_author
,build_email
,build_avatar
FROM repos LEFT OUTER JOIN (
SELECT DISTINCT ON (build_repo_id) * FROM builds
ORDER BY build_repo_id, build_id DESC
) b ON b.build_repo_id = repos.repo_id
INNER JOIN perms ON perms.perm_repo_id = repos.repo_id
WHERE perms.perm_user_id = $1
AND (perms.perm_push = true OR perms.perm_admin = true)
AND repos.repo_active = TRUE
ORDER BY repo_full_name ASC;
-- name: feed
SELECT
repo_owner
,repo_name
,repo_full_name
,build_number
,build_event
,build_status
,build_created
,build_started
,build_finished
,build_commit
,build_branch
,build_ref
,build_refspec
,build_remote
,build_title
,build_message
,build_author
,build_email
,build_avatar
FROM repos
INNER JOIN perms ON perms.perm_repo_id = repos.repo_id
INNER JOIN builds ON builds.build_repo_id = repos.repo_id
WHERE perms.perm_user_id = $1
AND (perms.perm_push = true OR perms.perm_admin = true)
ORDER BY build_id DESC
LIMIT 50