ADD: purge push log history; purge ignored addresses subscriptions

This commit is contained in:
overtorment 2023-04-08 09:36:23 +01:00
parent 9a5db5689d
commit f623fe3694
2 changed files with 42 additions and 10 deletions

View File

@ -1,17 +1,15 @@
const fs = require('fs');
const fs = require("fs");
const text = fs.readFileSync('all_tokens_unique.csv', {encoding: 'utf8'});
const text = fs.readFileSync("all_tokens_unique.csv", { encoding: "utf8" });
const lines = text.split('\n');
const lines = text.split("\n");
console.log('INSERT INTO send_queue_2 VALUES ');
console.log("INSERT INTO send_queue_2 VALUES ");
for (const line of lines.slice(50000, 60000)) {
const [token, os] = line.split('\t');
const sql = `(null, '{"type":5,"token":"${token}","os":"${os}","text":"If you are using Lightning, please read our blog post. The service is sunsetting. Balances should be moved to another service"}', null), `;
console.log(sql);
const [token, os] = line.split("\t");
const sql = `(null, '{"type":5,"token":"${token}","os":"${os}","text":"If you are using Lightning, please read our blog post. The service is sunsetting. Balances should be moved to another service"}', null), `;
console.log(sql);
}
console.log(';');
console.log(";");

View File

@ -57,12 +57,46 @@ const ADDRESS_IGNORE_LIST = [
"1CK6KHY6MHgYvmRQ4PAafKYDrg1ejbH1cE",
"36XWTfSYJJz3WSNPZVZ3q3aa5eFuJHR9nu",
"bc1qc8ee9860cdnkyej0ag5hf49pcx7uvz89lkwpr9",
"bc1q7ug4w4as2sefar89q057hnmxkakp58a25535ttlmurn6cncs8tms4e7gp2",
"3JodN7GmkHdPgKj9G7HCkn9NDLhrcWCjVN",
"bc1qujepl0k5n0ga2e86yskvxa6auehpf6dlf84dx0",
"bc1qg9lgqyukp2rup5x4frrz7hhw7988k5q26luakm",
"3JSdUu1ivm3rqMvuCTAdAj6Dc2hdVhHiEe",
];
let connection: DataSource;
const pushLogPurge = () => {
console.log("purging PushLog...");
let today = new Date();
connection
.createQueryBuilder()
.delete()
.from(PushLog)
.where("created <= :currentDate", { currentDate: new Date(today.getTime() - 3 * 24 * 60 * 60 * 1000) })
.execute()
.then(() => console.log("PushLog purged ok"))
.catch((error) => console.log("error purging PushLog:", error));
};
const purgeIgnoredAddressesSubscriptions = () => {
console.log("Purging addresses subscriptions...");
connection
.createQueryBuilder()
.delete()
.from(TokenToAddress)
.where("address IN (:...id)", { id: ADDRESS_IGNORE_LIST })
.execute()
.then(() => console.log("Addresses subscriptions purged ok"))
.catch((error) => console.log("error purging addresses subscriptions:", error));
};
dataSource.initialize().then((c) => {
console.log("db connected");
connection = c;
purgeIgnoredAddressesSubscriptions();
pushLogPurge();
setInterval(pushLogPurge, 3600 * 1000);
});
export class GroundController {