This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I discovered in the process that we were computing nusers wrong.
- Loading branch information
1 parent
a7666e1
commit e9158f1
Showing
9 changed files
with
46 additions
and
24 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
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,6 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE paydays RENAME COLUMN nactive TO nusers; | ||
ALTER TABLE paydays ADD COLUMN nteams integer NOT NULL DEFAULT 0; | ||
|
||
END; |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
-- Reset post-Gratipocalypse values | ||
-- Fix nusers and backfill nteams for post-Gratipocalypse paydays | ||
UPDATE paydays p | ||
SET nactive = (SELECT DISTINCT count(*) FROM ( | ||
SELECT participant FROM payments WHERE payday=p.id | ||
SET nteams = (SELECT count(*) FROM ( | ||
SELECT DISTINCT ON (team) team FROM payments WHERE payday=p.id GROUP BY team | ||
) AS foo) | ||
, nusers = (SELECT count(*) FROM ( | ||
SELECT DISTINCT ON (participant) participant FROM payments WHERE payday=p.id GROUP BY participant | ||
) AS foo) | ||
, volume = (SELECT COALESCE(sum(amount), 0) | ||
FROM payments | ||
WHERE payday=p.id AND direction='to-team') | ||
WHERE ts_start > '2015-05-07'::timestamptz; |
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
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