-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into improvement/async-mem…
…ber-affiliations-update
- Loading branch information
Showing
64 changed files
with
1,706 additions
and
1,314 deletions.
There are no files selected for viewing
Empty file.
36 changes: 36 additions & 0 deletions
36
backend/src/database/migrations/V1704365919__fix-member-joined-at.sql
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,36 @@ | ||
DO $$ | ||
DECLARE | ||
_member_id UUID; | ||
_first_acitivity TIMESTAMP; | ||
BEGIN | ||
FOR _member_id IN | ||
SELECT id | ||
FROM members | ||
WHERE EXTRACT(YEAR FROM "joinedAt") = 1970 -- those who have the wrong joinedAt | ||
AND EXISTS ( -- yet have at least one activity with a non-1970 timestamp | ||
SELECT 1 | ||
FROM activities a | ||
WHERE a."memberId" = members.id | ||
AND EXTRACT(YEAR FROM a.timestamp) != 1970 | ||
) | ||
LOOP | ||
RAISE NOTICE 'member_id: %', _member_id; | ||
|
||
-- find the actual first non-1970 activity timestamp | ||
SELECT MIN(a.timestamp) INTO _first_acitivity | ||
FROM activities a | ||
WHERE EXTRACT(YEAR FROM a.timestamp) != 1970 | ||
AND a."memberId" = _member_id; | ||
|
||
IF _first_acitivity IS NULL THEN | ||
CONTINUE; | ||
END IF; | ||
|
||
RAISE NOTICE 'first_acitivity: %', _first_acitivity; | ||
|
||
UPDATE members | ||
SET "joinedAt" = _first_acitivity | ||
WHERE id = _member_id; | ||
END LOOP; | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.