refactor: remove verbose debug logging from cospend API endpoints
Removed excessive console.log statements from recurring payments processing and monthly expenses aggregation. Error logging (console.error) is retained for troubleshooting.
This commit is contained in:
@@ -77,7 +77,6 @@ export const GET: RequestHandler = async ({ url, locals }) => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const results = await Payment.aggregate(pipeline);
|
const results = await Payment.aggregate(pipeline);
|
||||||
console.log('Aggregation results:', results);
|
|
||||||
|
|
||||||
// Transform data into chart-friendly format
|
// Transform data into chart-friendly format
|
||||||
const monthsMap = new Map();
|
const monthsMap = new Map();
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ export const POST: RequestHandler = async ({ request }) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
console.log(`[Cron] Starting recurring payments processing at ${now.toISOString()}`);
|
|
||||||
|
|
||||||
// Find all active recurring payments that are due
|
// Find all active recurring payments that are due
|
||||||
const duePayments = await RecurringPayment.find({
|
const duePayments = await RecurringPayment.find({
|
||||||
@@ -34,16 +33,12 @@ export const POST: RequestHandler = async ({ request }) => {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`[Cron] Found ${duePayments.length} due recurring payments`);
|
|
||||||
|
|
||||||
const results = [];
|
const results = [];
|
||||||
let successCount = 0;
|
let successCount = 0;
|
||||||
let failureCount = 0;
|
let failureCount = 0;
|
||||||
|
|
||||||
for (const recurringPayment of duePayments) {
|
for (const recurringPayment of duePayments) {
|
||||||
try {
|
try {
|
||||||
console.log(`[Cron] Processing recurring payment: ${recurringPayment.title} (${recurringPayment._id})`);
|
|
||||||
|
|
||||||
// Create the payment
|
// Create the payment
|
||||||
const payment = await Payment.create({
|
const payment = await Payment.create({
|
||||||
title: `${recurringPayment.title} (Auto)`,
|
title: `${recurringPayment.title} (Auto)`,
|
||||||
@@ -89,8 +84,6 @@ export const POST: RequestHandler = async ({ request }) => {
|
|||||||
success: true
|
success: true
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`[Cron] Successfully processed: ${recurringPayment.title}, next execution: ${nextExecutionDate.toISOString()}`);
|
|
||||||
|
|
||||||
} catch (paymentError) {
|
} catch (paymentError) {
|
||||||
console.error(`[Cron] Error processing recurring payment ${recurringPayment._id}:`, paymentError);
|
console.error(`[Cron] Error processing recurring payment ${recurringPayment._id}:`, paymentError);
|
||||||
failureCount++;
|
failureCount++;
|
||||||
@@ -104,8 +97,6 @@ export const POST: RequestHandler = async ({ request }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[Cron] Completed processing. Success: ${successCount}, Failures: ${failureCount}`);
|
|
||||||
|
|
||||||
return json({
|
return json({
|
||||||
success: true,
|
success: true,
|
||||||
timestamp: now.toISOString(),
|
timestamp: now.toISOString(),
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ export const POST: RequestHandler = async ({ request, locals }) => {
|
|||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'execute':
|
case 'execute':
|
||||||
console.log(`[API] Manual execution requested by ${auth.user.nickname}`);
|
|
||||||
await recurringPaymentScheduler.executeNow();
|
await recurringPaymentScheduler.executeNow();
|
||||||
return json({
|
return json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user