forked from TFNS/CTFNote
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request TFNS#27 from JJ-8/0-last-active-downstream
Add last active admin functionality
- Loading branch information
Showing
6 changed files
with
168 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
ALTER TABLE ctfnote.profile | ||
ADD COLUMN "lastactive" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP; | ||
|
||
|
||
/* UpdateLastActive */ | ||
CREATE FUNCTION ctfnote.update_last_active () | ||
RETURNS void | ||
AS $$ | ||
BEGIN | ||
UPDATE ctfnote.profile | ||
SET lastactive = now() | ||
WHERE id = ctfnote_private.user_id (); | ||
END; | ||
$$ | ||
LANGUAGE plpgsql VOLATILE | ||
SECURITY DEFINER; | ||
GRANT EXECUTE ON FUNCTION ctfnote.update_last_active () TO user_guest; | ||
|
||
CREATE OR REPLACE FUNCTION ctfnote.me () | ||
RETURNS ctfnote.profile | ||
AS $$ | ||
SELECT ctfnote.update_last_active(); | ||
SELECT | ||
* | ||
FROM | ||
ctfnote.profile | ||
WHERE | ||
id = ctfnote_private.user_id () | ||
LIMIT 1; | ||
|
||
$$ | ||
LANGUAGE SQL | ||
STRICT STABLE; |
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.