nba_league_rank.ts
1.3 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
/**
* Created by sunney on 7/19/17.
*/
import {db as Info} from '../table'
import { cache,redis as client, redis, task_lock } from '../../../cache'
export async function getNBALeagueRank(match:any) {
if(match.LotteryId == 72) {
return []
}
let match_NBALeagueRank_key = `${config.CachePrefix}match:matchNBALeagueRank:v2_${match.Id}`
let t = await client.get(match_NBALeagueRank_key);
if (t && t.length > 0 && ! match.isUpdateCache) {
return t
}
if(match.LotteryId == 73) {
t = await Info.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 []
client.set(match_NBALeagueRank_key, JSON.stringify(t[0]))
client.expire(match_NBALeagueRank_key, 60 *60*24)
return JSON.stringify(t[0]);
}
return []
};