1
Fork 0

Make queries prettier

This commit is contained in:
Jake Howard 2023-12-21 21:02:26 +00:00
parent 0f719e1dac
commit 45a417d7be
Signed by: jake
GPG Key ID: 57AFB45680EDD477
3 changed files with 38 additions and 2 deletions

19
date-audit.sql Normal file
View File

@ -0,0 +1,19 @@
SELECT
r.owner_name,
r.lower_name,
to_timestamp(
max(b.commit_time)
),
to_timestamp(r.updated_unix)
FROM
repository AS r
INNER JOIN branch b ON b.repo_id = r.id
where
r.is_archived = true
GROUP BY
r.owner_name,
r.lower_name,
r.updated_unix
ORDER BY
r.owner_name,
r.lower_name;

View File

@ -1 +0,0 @@
SELECT r.owner_name, r.lower_name, to_timestamp(max(b.commit_time)), to_timestamp(r.updated_unix) FROM repository AS r INNER JOIN branch b ON b.repo_id=r.id where r.is_archived=true GROUP BY r.owner_name, r.lower_name, r.updated_unix ORDER BY r.owner_name, r.lower_name;

View File

@ -1 +1,19 @@
UPDATE repository set updated_unix=sub.commit_time FROM (SELECT r.id, max(b.commit_time) as commit_time FROM repository AS r INNER JOIN branch b ON b.repo_id=r.id where r.is_archived=true GROUP BY r.id) as sub where repository.id = sub.id;
UPDATE
repository
set
updated_unix = sub.commit_time
FROM
(
SELECT
r.id,
max(b.commit_time) as commit_time
FROM
repository AS r
INNER JOIN branch b ON b.repo_id = r.id
where
r.is_archived = true
GROUP BY
r.id
) as sub
where
repository.id = sub.id;