Make queries prettier
This commit is contained in:
parent
0f719e1dac
commit
45a417d7be
3 changed files with 38 additions and 2 deletions
19
date-audit.sql
Normal file
19
date-audit.sql
Normal 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;
|
|
@ -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;
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue