Selaa lähdekoodia

删除无用的js

jax 5 kuukautta sitten
vanhempi
commit
844be1c6c9
1 muutettua tiedostoa jossa 0 lisäystä ja 71 poistoa
  1. 0 71
      src/app/api/cronTask/route.js

+ 0 - 71
src/app/api/cronTask/route.js

@@ -1,71 +0,0 @@
-// // src/app/api/cronTask/route.js
-// import { CronJob } from "cron";
-// import Match from "../../models/Match"; // 确保路径正确
-
-// const timezone = "Asia/Shanghai";
-// const now = moment.tz(timezone);
-// const currentDate = now.toDate();
-// const currentTimeString = now.format("HH:mm");
-
-// // 创建2小时前的时间点
-// const twoHoursAgo = moment(now).subtract(2, "hours");
-// const twoHoursAgoDate = twoHoursAgo.format("YYYY-MM-DD"); // 使用日期字符串
-// const twoHoursAgoTime = twoHoursAgo.format("HH:mm");
-// let job;
-
-// export async function GET(req) {
-//     if (!job) {
-//         // 设置定时任务,以下示例为每分钟执行一次
-//         job = new CronJob(
-//             "*/1 * * * *", // cron 表达式
-//             async () => {
-
-//                 // 更新所有开始超过2小时的比赛为已结束
-//                 Match.updateMany(
-//                     {
-//                         $or: [
-//                             // 早于今天的比赛
-//                             { date: { $lt: twoHoursAgoDate } },
-//                             // 今天的比赛且开始时间在2小时前
-//                             {
-//                                 date: twoHoursAgoDate,
-//                                 time: { $lte: twoHoursAgoTime },
-//                             },
-//                         ],
-//                         status: { $in: ["未开始", "进行中"] },
-//                         ...(type ? { type } : {}),
-//                     },
-//                     { $set: { status: "已结束" } }
-//                 ),
-
-//                     // 更新其他应该进行中的比赛
-//                     Match.updateMany(
-//                         {
-//                             date: { $lte: currentDate },
-//                             time: { $lte: currentTimeString },
-//                             status: "未开始",
-//                             // 排除已经过去2小时的比赛(因为上面的查询会处理)
-//                             $or: [
-//                                 { date: { $gt: twoHoursAgoDate } },
-//                                 {
-//                                     date: twoHoursAgoDate,
-//                                     time: { $gt: twoHoursAgoTime },
-//                                 },
-//                             ],
-//                             ...(type ? { type } : {}),
-//                         },
-//                         { $set: { status: "进行中" } }
-//                     )
-
-//             },
-//             null,
-//             true, // 设置自动启动任务
-//             "Asia/Shanghai" // 设置时区(可选)
-//         );
-//     }
-
-//     return new Response(JSON.stringify({ message: "定时任务已启动" }), {
-//         status: 200,
-//         headers: { "Content-Type": "application/json" },
-//     });
-// }