diff options
| author | Louis Burda <quent.burda@gmail.com> | 2022-11-06 02:13:05 +0100 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2022-11-06 02:25:47 +0100 |
| commit | 0f41cfe1b25571493bd523349ab5f835c4a84819 (patch) | |
| tree | 7e81a3eb32c516c4598fac73f51a46ae5e2aa5c2 | |
| parent | 42c73528483b6a61ebe6c355c089d11f3ef8efca (diff) | |
| download | bambi7-service-fireworx-0f41cfe1b25571493bd523349ab5f835c4a84819.tar.gz bambi7-service-fireworx-0f41cfe1b25571493bd523349ab5f835c4a84819.zip | |
Switch from user creation to deletion time for cleanup
| -rw-r--r-- | service/init.sql | 8 | ||||
| -rwxr-xr-x | service/run.sh | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/service/init.sql b/service/init.sql index fdcf10a..b4cc4fc 100644 --- a/service/init.sql +++ b/service/init.sql @@ -1,6 +1,6 @@ CREATE TABLE IF NOT EXISTS users( id INTEGER PRIMARY KEY AUTOINCREMENT, - creat INTEGER DEFAULT NULL, + delet INTEGER DEFAULT NULL, name TEXT UNIQUE, p TEXT, q TEXT, @@ -21,8 +21,8 @@ CREATE TABLE IF NOT EXISTS events( CREATE INDEX IF NOT EXISTS users_name ON users(name); -CREATE TRIGGER IF NOT EXISTS users_creat +CREATE TRIGGER IF NOT EXISTS users_delete_by AFTER INSERT ON users BEGIN - UPDATE users SET creat = strftime("%s", "now") WHERE creat IS NULL; -END + UPDATE users SET delet = strftime("%s", "now") + 780 WHERE delet IS NULL; +END; diff --git a/service/run.sh b/service/run.sh index c351996..5daf45f 100755 --- a/service/run.sh +++ b/service/run.sh @@ -6,7 +6,7 @@ sqlite3 /service/data/db.sqlite < init.sql while true; do sqlite3 /service/data/db.sqlite \ "PRAGMA foreign_keys = ON; \ - DELETE FROM users WHERE creat < strftime('%s', 'now') - 780" + DELETE FROM users WHERE delet < strftime('%s', 'now')" sleep 60 done & |
