Created
November 5, 2015 03:40
-
-
Save adaiguoguo/45556b6d570687fa7f32 to your computer and use it in GitHub Desktop.
postgres count gitlab pr &push
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
SELECT aa.datetime, | |
aa.cc pushed, | |
bb.cc pr | |
FROM (SELECT To_char(created_at, 'YYYY-MM-DD') datetime, | |
Count (1) cc | |
FROM EVENTS | |
WHERE action = 5 | |
AND created_at > NOW() - '30 DAY'::INTERVAL | |
GROUP BY To_char(created_at, 'YYYY-MM-DD'), | |
target_type, | |
action | |
ORDER BY To_char(created_at, 'YYYY-MM-DD')) aa | |
left join (SELECT To_char(created_at, 'YYYY-MM-DD') datetime, | |
Count (1) cc | |
FROM EVENTS | |
WHERE target_type = 'MergeRequest' | |
AND action = 1 | |
AND created_at > NOW() - '30 DAY'::INTERVAL | |
GROUP BY To_char(created_at, 'YYYY-MM-DD'), | |
target_type, | |
action | |
ORDER BY To_char(created_at, 'YYYY-MM-DD')) bb | |
ON aa.datetime = bb.datetime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment