const weeklyReportTask = hy.task({
name: 'weeklyReport',
config: {
cron: '0 9 * * 1', // Every Monday at 9 AM
queue: 'reports',
timeoutSeconds: 600
},
func: async () => {
const endDate = new Date();
const startDate = new Date();
startDate.setDate(startDate.getDate() - 7);
const reportData = await gatherWeeklyMetrics(startDate, endDate);
const report = await generateReport(reportData);
await sendEmail({
to: 'team@company.com',
subject: `Weekly Report - ${endDate.toLocaleDateString()}`,
body: report
});
return { sent: true, week: startDate };
}
});