代码提交
This commit is contained in:
+22
-2
@@ -94,7 +94,7 @@ func DailyBotReportTask(ctx context.Context, bot *tgbot.TgBot, appId int32, repo
|
||||
//text := report.DisplayDayHourText(appName, report)
|
||||
//_ = bot.SendBroadcastMessage(text, "", tgbot.FileTypeNone)
|
||||
|
||||
text, title, desc := report.DisplayDayHourTextWithTitle(appName, historyReport)
|
||||
text, title, desc := report.DisplayDayHourTextWithTitle(appName, historyReport, lastWeekHourStat(ctx, appId, reportTime))
|
||||
et := tgbot.NewEntityList(title, desc, []*tgbot.Entity{
|
||||
{
|
||||
Content: text,
|
||||
@@ -144,7 +144,7 @@ func DailyBotReportInfo(ctx context.Context, appId int32, reportTime time.Time)
|
||||
appNameMap, _ := appInfoMod.GetAllAppIdNameMap(ctx)
|
||||
appName := appNameMap[appId]
|
||||
if statg.GlobalEndpoints.GetBotStatEndpoints().ExistsByAppId(appId) {
|
||||
text, title, desc = report.DisplayDayHourTextWithTitle(appName, historyReport)
|
||||
text, title, desc = report.DisplayDayHourTextWithTitle(appName, historyReport, lastWeekHourStat(ctx, appId, reportTime))
|
||||
}
|
||||
log.Error("DailyBotReportTask end", log.Any("appid", appId),
|
||||
log.Any("time", reportTime))
|
||||
@@ -347,3 +347,23 @@ func BotDailyHourStat(ctx context.Context, appId int32, reportTime time.Time, sa
|
||||
}
|
||||
return report, nil
|
||||
}
|
||||
|
||||
// lastWeekHourStat 取上周当日同一小时的统计记录,给汇报里的"环比"做基准。
|
||||
// 只查不补算: 现算一份七天前的数据要把当天的原始流水全量聚合一遍,代价高,
|
||||
// 而且历史原始数据可能已经被清理,算出来反而是错的。查不到就返回 nil,
|
||||
// 展示层会把那一行标成"无数据"。
|
||||
func lastWeekHourStat(ctx context.Context, appId int32, reportTime time.Time) *botdailyhourstat.BotHourStat {
|
||||
filter := bson.M{
|
||||
botreport.FN.BotReport.AppId: appId,
|
||||
botreport.FN.BotReport.SumDate: reportTime.AddDate(0, 0, -7),
|
||||
}
|
||||
report, err := botdailyhourstat.FindOneBotHourStatEx(ctx, filter)
|
||||
if err != nil {
|
||||
if err != mongo.ErrNoDocuments {
|
||||
log.Warn("lastWeekHourStat failed", log.E(err),
|
||||
log.Any("appId", appId), log.Any("sumDate", reportTime))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return report
|
||||
}
|
||||
|
||||
@@ -491,7 +491,7 @@ func DailyStat(ctx context.Context, cmd *tgbot.Command, moveBackDays int) error
|
||||
return tgbot.NewUserError(cmd, "服务器错误:"+err.Error())
|
||||
}
|
||||
}
|
||||
text, title, desc := report.DisplayDayHourTextWithTitle(appInfo.Name, historyReport)
|
||||
text, title, desc := report.DisplayDayHourTextWithTitle(appInfo.Name, historyReport, lastWeekHourStat(ctx, appId, reportTime))
|
||||
et := tgbot.NewEntityList(title, desc, []*tgbot.Entity{
|
||||
{
|
||||
Content: text,
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
downloadinfo "stat/models/downloadinfo"
|
||||
"stat/models/versionMod"
|
||||
"stat/service/cacheSer"
|
||||
"stat/service/cpcDownloadCfgSer"
|
||||
"stat/service/crossSer"
|
||||
"stat/statg"
|
||||
"strings"
|
||||
@@ -189,6 +190,18 @@ func PageButtonClick(ctx context.Context, userAgent string, peerIP string, req *
|
||||
return
|
||||
}
|
||||
|
||||
// 双端下载配置里给该渠道配了 Android 下载地址,就用它覆盖 link 并直接返回。
|
||||
// link 也改: 只读 data.link 的老客户端(useAppDownload.ts)才能用上渠道包;
|
||||
// 客户端取值是 links[index] || links[0],单元素数组任意下标都能回落。
|
||||
// 必须在批量打包逻辑之前返回: 下面那段会按默认域名重算并覆盖 link。
|
||||
if req.Terminal == "android" && channelCode.DC != "" {
|
||||
if packUrl := channelApkDownUrl(ctx, req.AppId, channelCode.DC); packUrl != "" {
|
||||
resp.ChannelApkAndDownUrl = packUrl
|
||||
resp.Link = []string{packUrl}
|
||||
return resp, nil
|
||||
}
|
||||
}
|
||||
|
||||
// 新增批量打包逻辑
|
||||
if req.Terminal == "android" && len(data.Md5) > 0 {
|
||||
randTime := int64(60*60) + int64(rand.Intn(60*60))
|
||||
@@ -273,6 +286,22 @@ func PageButtonClick(ctx context.Context, userAgent string, peerIP string, req *
|
||||
return
|
||||
}
|
||||
|
||||
// channelApkDownUrl 取双端下载配置里该渠道的 Android 下载地址,只用于落地页按钮。
|
||||
// 配置里有一部分填的是落地页地址(形如 https://xxx?dc=blt0001)而不是 apk 包,
|
||||
// 落地页拿到它会再跳一次落地页,所以带 dc 参数的一律当没配,返回空串让调用方走默认下载链接。
|
||||
// 不能直接改 cpcDownloadCfgSer.GetDownloadUrl: /download/{appId}/{channel} 这条双端路由
|
||||
// 依赖它跳落地页,过滤掉会把那个功能弄坏。
|
||||
func channelApkDownUrl(ctx context.Context, appId int32, dc string) string {
|
||||
url := cpcDownloadCfgSer.GetDownloadUrl(ctx, appId, dc)
|
||||
if url == "" {
|
||||
return ""
|
||||
}
|
||||
if strings.Contains(url, "?dc=") || strings.Contains(url, "&dc=") {
|
||||
return ""
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
// PageButtonList 落地页获取下载按钮
|
||||
func PageButtonList(ctx context.Context, isIos bool, peerIP string, req *proto.PageButtonListReq) (resp *proto.PageButtonListResp, err error) {
|
||||
resp = &proto.PageButtonListResp{
|
||||
@@ -377,5 +406,10 @@ func PageButtonList(ctx context.Context, isIos bool, peerIP string, req *proto.P
|
||||
resp.HasChannelApk = true
|
||||
}
|
||||
|
||||
// 双端下载配置里给该渠道配了 Android 下载地址就一并返回,落地页优先用它
|
||||
if !isIos && channelCode.DC != "" {
|
||||
resp.ChannelApkAndDownUrl = channelApkDownUrl(ctx, req.AppId, channelCode.DC)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user