mirror of
https://github.com/frappe/books.git
synced 2026-08-24 02:24:17 -05:00
fix: removed the unused codes
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
import { parentPort } from 'worker_threads';
|
||||
import { DatabaseManager } from '../backend/database/manager';
|
||||
import { ModelNameEnum } from '../models/types';
|
||||
|
||||
if (parentPort) {
|
||||
parentPort.postMessage({ type: 'check-loyalty-program-expiry' });
|
||||
}
|
||||
|
||||
export async function checkLoyaltyProgramExpiry() {
|
||||
const dm = new DatabaseManager();
|
||||
|
||||
@@ -25,13 +20,8 @@ export async function checkLoyaltyProgramExpiry() {
|
||||
isEnabled: boolean;
|
||||
}>;
|
||||
|
||||
let expiredCount = 0;
|
||||
let processedCount = 0;
|
||||
|
||||
if (loyaltyPrograms) {
|
||||
for (const program of loyaltyPrograms) {
|
||||
processedCount++;
|
||||
|
||||
if (program.toDate && new Date(program.toDate) <= currentDate) {
|
||||
await dm.db?.knex!(ModelNameEnum.LoyaltyProgram)
|
||||
.where({ name: program.name })
|
||||
@@ -39,41 +29,16 @@ export async function checkLoyaltyProgramExpiry() {
|
||||
status: 'Expired',
|
||||
isEnabled: false,
|
||||
});
|
||||
|
||||
expiredCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const result = {
|
||||
timestamp: currentDate.toISOString(),
|
||||
processedPrograms: processedCount,
|
||||
expiredPrograms: expiredCount,
|
||||
message: `Loyalty program expiry check completed. ${expiredCount} programs expired out of ${processedCount} processed.`,
|
||||
};
|
||||
|
||||
if (parentPort) {
|
||||
parentPort.postMessage({
|
||||
type: 'loyalty-program-expiry-complete',
|
||||
data: result,
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
const errorResult = {
|
||||
timestamp: new Date().toISOString(),
|
||||
error: error instanceof Error ? error.message : 'Unknown error',
|
||||
message: 'Loyalty program expiry check failed',
|
||||
};
|
||||
|
||||
if (parentPort) {
|
||||
parentPort.postMessage({
|
||||
type: 'loyalty-program-expiry-error',
|
||||
data: errorResult,
|
||||
});
|
||||
}
|
||||
|
||||
throw error;
|
||||
} finally {
|
||||
await dm.call('close');
|
||||
@@ -81,16 +46,5 @@ export async function checkLoyaltyProgramExpiry() {
|
||||
}
|
||||
|
||||
checkLoyaltyProgramExpiry().catch((error) => {
|
||||
const errorResult = {
|
||||
timestamp: new Date().toISOString(),
|
||||
error: error instanceof Error ? error.message : 'Unknown error',
|
||||
message: 'Loyalty program expiry check failed',
|
||||
};
|
||||
|
||||
if (parentPort) {
|
||||
parentPort.postMessage({
|
||||
type: 'loyalty-program-expiry-error',
|
||||
data: errorResult,
|
||||
});
|
||||
}
|
||||
throw error;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user