ms_schedule.js 2.1 KB
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMsSchedulesByCoreIds = exports.getMsSchedulesByLottery = void 0;
const infodb = require("../table");
const moment = require("moment");
const cache_1 = require("../../../cache");
//ms_schedule
async function getMsSchedulesByLottery({ lotteryId }) {
    let key = `${config.CachePrefix}match:match_ms_schedule:v1_${moment().add(-10, 'day').format('YYYY-MM-DD')}_${lotteryId}`;
    let reply = await cache_1.redis.get(key);
    if (reply) {
        return JSON.parse(reply);
    }
    let result = await infodb.ms_schedule.findAll({
        where: {
            core_lottery_id: lotteryId,
            core_match_time: { $gt: moment().add(-10, 'day').format('YYYY-MM-DD') },
        },
        limit: 1000,
        attributes: ['core_match_id', 'sportsdt_match_id', 'sportsdt_host_team_id',
            'sportsdt_guest_team_id', 'sportsdt_competition_id', 'sportsdt_type', 'sportsdt_degree',
            'sportsdt_num', 'sportsdt_starttime', 'sportsdt_isah'],
    });
    await cache_1.redis.set(key, JSON.stringify(result));
    await cache_1.redis.expire(key, 60 * 10);
    return result;
}
exports.getMsSchedulesByLottery = getMsSchedulesByLottery;
async function getMsSchedulesByCoreIds({ CoreIds }) {
    return (0, cache_1.cache)(async ({ CoreIds }) => {
        let result = (await infodb.ms_schedule.findAll({
            where: {
                core_match_id: { $in: CoreIds },
                core_match_time: { $gt: moment().add(-120, 'day').format('YYYY-MM-DD') },
            },
            limit: 1000,
            attributes: ['core_match_id', 'sportsdt_match_id', 'sportsdt_host_team_id',
                'sportsdt_guest_team_id', 'sportsdt_competition_id', 'sportsdt_type', 'sportsdt_degree',
                'sportsdt_num', 'sportsdt_starttime', 'sportsdt_isah', 'sportsdt_n',
                'yiqiu_match_id', 'sporttery_match_id', 'w500_match_id', 'info_match_id'],
        })).map((o) => o.dataValues);
        return result;
    }, { CoreIds }, 10, "getMsSchedulesByCoreIds:v1", 60, 100);
}
exports.getMsSchedulesByCoreIds = getMsSchedulesByCoreIds;
//# sourceMappingURL=ms_schedule.js.map