nba_league_rank.js
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNBALeagueRank = void 0;
/**
* Created by sunney on 7/19/17.
*/
const table_1 = require("../table");
const cache_1 = require("../../../cache");
async function getNBALeagueRank(match) {
if (match.LotteryId == 72) {
return [];
}
let match_NBALeagueRank_key = `${config.CachePrefix}match:matchNBALeagueRank:v2_${match.Id}`;
let t = await cache_1.redis.get(match_NBALeagueRank_key);
if (t && t.length > 0 && !match.isUpdateCache) {
return t;
}
if (match.LotteryId == 73) {
t = await table_1.db.db.query(`SELECT
a.Id,a.TeamId,c.Name as TeamName,c.ShortName TeamShortNam,a.Win,a.Lose,a.WinPoint,
a.LosePoint,a.WinAverage,a.LostAverage,a.State,a.Type,b.FullName
as MatchTypeName,b.ShortName as MatchTypeShortName
FROM T_NBAMatch t
join T_NBALeagueRank a on a.MatchSeason=t.MatchSeason and a.MatchTypeId=t.MatchTypeId
JOIN T_NBAMatchType b ON a.MatchTypeId=b.Id AND b.ParentId=0 AND a.MatchSeason=t.MatchSeason and a.MatchTypeId=t.MatchTypeId
JOIN T_NBATeam c ON a.TeamId=c.Id
where t.Id=${match.InfoId}
ORDER BY Type, Id
`);
if (t == null || t.length == 0)
return [];
cache_1.redis.set(match_NBALeagueRank_key, JSON.stringify(t[0]));
cache_1.redis.expire(match_NBALeagueRank_key, 60 * 60 * 24);
return JSON.stringify(t[0]);
}
return [];
}
exports.getNBALeagueRank = getNBALeagueRank;
;
//# sourceMappingURL=nba_league_rank.js.map