#1596 and revert cronjob
All checks were successful
Build & Deploy on Dev / build (push) Successful in 59s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 59s
This commit is contained in:
parent
e2aeabf155
commit
c398354208
2 changed files with 37 additions and 2 deletions
|
|
@ -66,8 +66,7 @@ async function main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cron job for updating org revision - every day at 01:00:00
|
// Cron job for updating org revision - every day at 01:00:00
|
||||||
// const cronTime = "0 0 1 * * *";
|
const cronTime = "0 0 1 * * *";
|
||||||
const cronTime = "0 30 14 * * *";
|
|
||||||
cron.schedule(cronTime, async () => {
|
cron.schedule(cronTime, async () => {
|
||||||
try {
|
try {
|
||||||
const orgController = new OrganizationController();
|
const orgController = new OrganizationController();
|
||||||
|
|
|
||||||
|
|
@ -8702,6 +8702,42 @@ export class OrganizationController extends Controller {
|
||||||
};
|
};
|
||||||
|
|
||||||
await queryRunner.commitTransaction();
|
await queryRunner.commitTransaction();
|
||||||
|
|
||||||
|
// Clear Redis cache after successful publish
|
||||||
|
const redis = require("redis");
|
||||||
|
const { promisify } = require("util");
|
||||||
|
const redisClient = redis.createClient({
|
||||||
|
host: process.env.REDIS_HOST || "localhost",
|
||||||
|
port: parseInt(process.env.REDIS_PORT || "6379"),
|
||||||
|
});
|
||||||
|
const keysAsync = promisify(redisClient.keys).bind(redisClient);
|
||||||
|
const delAsync = promisify(redisClient.del).bind(redisClient);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [posMasterKeys, userKeys, orgKeys, menuKeys, roleKeys] = await Promise.all([
|
||||||
|
keysAsync("posMaster_*"),
|
||||||
|
keysAsync("user_*"),
|
||||||
|
keysAsync("org_*"),
|
||||||
|
keysAsync("menu_*"),
|
||||||
|
keysAsync("role_*"),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (posMasterKeys.length > 0) await delAsync(...posMasterKeys);
|
||||||
|
if (userKeys.length > 0) await delAsync(...userKeys);
|
||||||
|
if (orgKeys.length > 0) await delAsync(...orgKeys);
|
||||||
|
if (menuKeys.length > 0) await delAsync(...menuKeys);
|
||||||
|
if (roleKeys.length > 0) await delAsync(...roleKeys);
|
||||||
|
|
||||||
|
console.log(`[moveDraftToCurrent] Cleared cache: posMaster=${posMasterKeys.length}, user=${userKeys.length}, org=${orgKeys.length}, menu=${menuKeys.length}, role=${roleKeys.length}`);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("[moveDraftToCurrent] Error clearing cache:", err);
|
||||||
|
} finally {
|
||||||
|
redisClient.quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invalidate memory cache
|
||||||
|
orgStructureCache.invalidate(currentRevisionId);
|
||||||
|
|
||||||
return new HttpSuccess(summary);
|
return new HttpSuccess(summary);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error moving draft to current:", error);
|
console.error("Error moving draft to current:", error);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue