Compare commits

...

254 Commits

Author SHA1 Message Date
root
8de1be36d8 remove no use 2020-03-09 12:04:31 +08:00
pengtao
623e5788c1 调整仅仅 2001 计算倒量数据 2019-12-13 15:50:46 +08:00
pengtao
025c3ec0d5 调整仅仅 2001 计算倒量数据 2019-12-13 11:47:55 +08:00
pengtao
a7b9d59f51 调整仅仅 2001 计算倒量数据 2019-12-13 11:40:47 +08:00
pengtao
d37b1bfe36 调整仅仅 2001 计算倒量数据 2019-12-13 11:36:48 +08:00
root
c7d9351702 change report start values 2019-12-12 09:59:28 +08:00
pengtao
1475a0cff5 调整日报规则 添加一些gameid 2019-12-11 15:31:03 +08:00
pengtao
319fadb8cc 调整日报规则 添加一些gameid 2019-12-11 15:22:44 +08:00
pengtao
6e75f61592 调整日报规则 添加一些gameid 2019-12-11 15:08:38 +08:00
pengtao
e2a3af6d77 调整日报规则 添加一些gameid 2019-12-11 15:08:17 +08:00
pengtao
822ad529d7 调整日报规则 添加一些gameid 2019-12-11 15:02:30 +08:00
pengtao
9d857e2c1c 调整日报规则 添加一些gameid 2019-12-11 14:57:59 +08:00
pengtao
2bb40a31d9 游戏日报添加2003 项目 2019-12-09 10:44:31 +08:00
pengtao
cfe454ac37 针对tap 的tags 数据基于order进行评分 2019-12-09 10:39:02 +08:00
pengtao
5b8010d5c9 针对tap 的tags 数据基于order进行评分 2019-12-05 20:16:52 +08:00
pengtao
1664d50211 针对tap 的tags 数据基于order进行评分 2019-12-05 15:02:07 +08:00
pengtao
f62f320149 针对tap 的tags 数据基于order进行评分 2019-12-05 15:01:42 +08:00
pengtao
7ed69b5a5e 针对tap 的tags 数据基于order进行评分 2019-12-05 15:01:12 +08:00
pengtao
6f2a2d3af5 针对tap 的tags 数据基于order进行评分 2019-12-05 14:53:59 +08:00
pengtao
49289c0519 针对tap 的tags 数据基于order进行评分 2019-12-05 14:53:48 +08:00
pengtao
8aabcbad35 针对tap 的tags 数据基于order进行评分 2019-12-05 14:39:08 +08:00
pengtao
a078193d41 针对tap 的tags 数据基于order进行评分 2019-12-05 14:34:04 +08:00
pengtao
8106a06250 针对tap 的tags 数据基于order进行评分 2019-12-05 14:31:01 +08:00
pengtao
f728c7d060 针对tap 的tags 数据基于order进行评分 2019-12-05 14:28:58 +08:00
pengtao
58224bb728 针对tap 的tags 数据基于order进行评分 2019-12-05 14:25:41 +08:00
pengtao
f6be1ac090 针对tap 的tags 数据基于order进行评分 2019-12-05 14:22:53 +08:00
pengtao
ac856a98bc 针对tap 的tags 数据基于order进行评分 2019-12-05 14:22:12 +08:00
pengtao
d8fdbf0020 针对tap 的tags 数据基于order进行评分 2019-12-05 12:03:11 +08:00
pengtao
a0ba7d50f7 1 2019-12-02 15:47:13 +08:00
pengtao
2d64a8dae7 添加tap 2 influxdb脚本 2019-11-27 16:06:40 +08:00
pengtao
93117d1745 添加tap 2 influxdb脚本 2019-11-27 16:05:29 +08:00
pengtao
820d100ae0 添加tap 2 influxdb脚本 2019-11-27 16:04:28 +08:00
pengtao
5157037e3f 添加tap 2 influxdb脚本 2019-11-27 15:22:28 +08:00
pengtao
9290622622 添加tap 2 influxdb脚本 2019-11-27 11:51:45 +08:00
pengtao
dcd30e5ce4 添加tap 2 influxdb脚本 2019-11-27 11:50:25 +08:00
pengtao
d1b1039feb 添加tap 2 influxdb脚本 2019-11-27 11:49:44 +08:00
pengtao
9bc68a58f4 添加tap 2 influxdb脚本 2019-11-27 11:47:02 +08:00
pengtao
afade09004 添加tap 2 influxdb脚本 2019-11-27 11:45:24 +08:00
pengtao
b65a1bcdb1 添加tap 2 influxdb脚本 2019-11-27 11:42:59 +08:00
pengtao
69e76a7e90 添加tap 2 influxdb脚本 2019-11-27 11:39:42 +08:00
pengtao
9b9908afed 添加tap 2 influxdb脚本 2019-11-27 11:36:14 +08:00
pengtao
56e82f6fa4 添加tap 2 influxdb脚本 2019-11-27 11:34:35 +08:00
pengtao
b3020f97bf 添加tap 2 influxdb脚本 2019-11-27 11:33:40 +08:00
pengtao
38fa5ba7ca 添加tap 2 influxdb脚本 2019-11-27 11:33:26 +08:00
pengtao
221cf8032d 添加tap 2 influxdb脚本 2019-11-27 11:28:54 +08:00
pengtao
ab340f4574 添加发件人 2019-11-26 11:26:36 +08:00
pengtao
d764e5f779 weekly cron job 2019-11-26 11:24:02 +08:00
pengtao
6da9e555fe weekly cron job 2019-11-26 11:20:17 +08:00
pengtao
66f92eee97 weekly cron job 2019-11-26 11:19:24 +08:00
pengtao
1c3db98f35 weekly cron job 2019-11-26 10:01:58 +08:00
pengtao
fde2f170e2 11 2019-11-25 19:38:23 +08:00
pengtao
4a24f0cc63 Merge branch 'master' of http://git.kingsome.cn/ops/datacollect
# Conflicts:
#	daily_report/templates/tap_weekly.html
2019-11-25 19:36:28 +08:00
yulixing
7c57542973 样式修改 2019-11-25 19:33:12 +08:00
pengtao
8d873931cb Merge remote-tracking branch 'origin/master'
# Conflicts:
#	daily_report/templates/tap_weekly.html
2019-11-25 19:14:38 +08:00
pengtao
e361f900b8 fixbug 2019-11-25 19:14:05 +08:00
yulixing
66a1ede58b 样式修改 2019-11-25 17:34:51 +08:00
yulixing
b46a81bee4 样式修改 2019-11-25 17:29:41 +08:00
pengtao
18599e4433 fixbug 2019-11-25 15:21:52 +08:00
pengtao
cc43e2b680 fixbug 2019-11-25 15:20:00 +08:00
pengtao
66b373568c fixbug 2019-11-25 15:12:55 +08:00
pengtao
4802210df8 fixbug 2019-11-25 15:08:34 +08:00
pengtao
9ce2ba817e fixbug 2019-11-25 15:03:34 +08:00
root
30c249f1fe a 2019-11-25 14:55:46 +08:00
pengtao
503d292559 fixbug 2019-11-25 14:50:21 +08:00
root
c34e1c15b4 a 2019-11-25 14:48:44 +08:00
pengtao
ab11874cfe fixbug 2019-11-25 14:45:38 +08:00
pengtao
27dab2272d fixbug 2019-11-25 14:44:05 +08:00
pengtao
90e4986353 fixbug 2019-11-25 14:42:39 +08:00
pengtao
7992e1f300 fixbug 2019-11-25 14:40:18 +08:00
pengtao
eb42a4f282 fixbug 2019-11-22 17:03:44 +08:00
pengtao
f8edaf610f fixbug 2019-11-22 16:58:14 +08:00
pengtao
8804a8a69c fixbug 2019-11-22 16:44:44 +08:00
pengtao
7d05904b64 fixbug 2019-11-22 16:42:54 +08:00
yulixing
d24eedcbc4 taptap 周报样式修改 2019-11-22 16:42:03 +08:00
yulixing
3cb3348cd4 taptap 周报样式修改 2019-11-22 16:40:39 +08:00
pengtao
44a2413b3f fixbug 2019-11-22 13:58:58 +08:00
pengtao
fd3b65b06b fixbug 2019-11-22 13:58:37 +08:00
pengtao
b8407a1f38 fixbug 2019-11-22 13:56:50 +08:00
pengtao
97cc0efd2c fixbug 2019-11-22 13:55:45 +08:00
pengtao
086b9451f4 fixbug 2019-11-22 13:54:57 +08:00
pengtao
c6b46993ee Merge remote-tracking branch 'origin/master' 2019-11-22 13:47:31 +08:00
pengtao
53d09cc66e fixbug 2019-11-22 13:47:24 +08:00
root
d49af8e435 f 2019-11-22 12:03:32 +08:00
pengtao
668e5cb00b fixbug 2019-11-22 12:02:35 +08:00
pengtao
b1b43cebc1 fixbug 2019-11-22 12:00:58 +08:00
pengtao
145d7ad161 fixbug 2019-11-22 11:55:47 +08:00
pengtao
c2908cda43 fixbug 2019-11-22 11:52:51 +08:00
pengtao
67a100dc5c fixbug 2019-11-22 11:48:51 +08:00
pengtao
4054124b95 fixbug 2019-11-22 11:47:51 +08:00
pengtao
4b29798718 fixbug 2019-11-22 11:46:11 +08:00
root
f6c5886587 f 2019-11-22 11:45:19 +08:00
pengtao
6b9f2ea198 fixbug 2019-11-22 11:40:54 +08:00
pengtao
db302dfaa9 fixbug 2019-11-22 11:40:37 +08:00
pengtao
be867ea227 fixbug 2019-11-22 11:37:47 +08:00
pengtao
b268b5a2ce fixbug 2019-11-22 11:35:49 +08:00
pengtao
18d704b076 fixbug 2019-11-22 11:35:03 +08:00
pengtao
e8927e7254 fixbug 2019-11-22 11:33:32 +08:00
pengtao
87eed702fb fixbug 2019-11-22 11:32:43 +08:00
pengtao
59219aca91 fixbug 2019-11-22 11:31:49 +08:00
pengtao
87b6f7fd59 fixbug 2019-11-22 11:30:10 +08:00
pengtao
b04ac14e8c fixbug 2019-11-22 11:26:33 +08:00
pengtao
9840f0ac64 fixbug 2019-11-21 20:24:57 +08:00
pengtao
60c0314fcc fixbug 2019-11-21 20:23:13 +08:00
pengtao
8fcb4b3030 fixbug 2019-11-21 17:28:05 +08:00
pengtao
8a50234942 fixbug 2019-11-21 17:25:41 +08:00
pengtao
c4819bd7e5 fixbug 2019-11-21 17:24:39 +08:00
pengtao
b9352026ec fixbug 2019-11-21 17:21:32 +08:00
pengtao
9373f843c4 fixbug 2019-11-21 10:26:05 +08:00
root
5ce41d5644 a 2019-11-21 10:24:25 +08:00
pengtao
1f96372e33 remove no use 2019-11-21 10:02:31 +08:00
pengtao
21fafdedb3 remove no use 2019-11-21 09:59:23 +08:00
pengtao
1d957828b8 fix data 2019-11-20 20:00:27 +08:00
pengtao
62163a7667 fix data 2019-11-20 19:53:54 +08:00
pengtao
a1c2e8bfbe fix data 2019-11-20 17:07:05 +08:00
pengtao
ef8d6dfd0a fix data 2019-11-20 17:03:24 +08:00
pengtao
a8d4cbaf7c fix data 2019-11-20 16:49:07 +08:00
pengtao
7f0ff0f4fe fix data 2019-11-20 16:48:16 +08:00
pengtao
78bec95408 fix data 2019-11-20 16:18:54 +08:00
pengtao
cf0ab1bf68 fix data 2019-11-20 16:15:20 +08:00
pengtao
c125a7da0c fix data 2019-11-20 16:13:31 +08:00
pengtao
9ef914b492 fix data 2019-11-20 16:11:10 +08:00
pengtao
f834cf8aa1 fix data 2019-11-20 16:09:49 +08:00
pengtao
c688aed024 fix data 2019-11-20 16:08:55 +08:00
pengtao
89303b7b72 fix data 2019-11-20 16:05:32 +08:00
pengtao
1103d670fa fix data 2019-11-20 16:00:51 +08:00
pengtao
55da4d4864 fix data 2019-11-20 16:00:20 +08:00
pengtao
df89597db2 调整HTML模板 2019-11-20 15:49:03 +08:00
pengtao
49cbbcaf33 fix data 2019-11-20 15:08:35 +08:00
pengtao
e079bc2b62 新增周报脚本1 2019-11-20 14:23:53 +08:00
pengtao
0bba893fa1 新增周报脚本1 2019-11-20 14:23:14 +08:00
pengtao
7f0f0622aa 新增周报脚本1 2019-11-20 14:21:22 +08:00
pengtao
7517f5eb92 新增周报脚本 2019-11-20 14:20:48 +08:00
pengtao
eb9d257a1e 新增周报脚本 2019-11-20 14:17:35 +08:00
pengtao
32235d2114 新增周报脚本 2019-11-20 14:00:54 +08:00
pengtao
3529c95491 新增周报脚本 2019-11-20 13:54:30 +08:00
pengtao
fd007e88c3 新增周报脚本 2019-11-20 13:53:35 +08:00
pengtao
8ca93678d8 新增周报脚本 2019-11-20 13:48:02 +08:00
pengtao
4e7de25c4c 新增周报脚本 2019-11-20 11:47:21 +08:00
pengtao
ba2f7ce4b7 新增周报脚本 2019-11-20 11:42:45 +08:00
pengtao
39340e40f1 新增周报脚本 2019-11-20 11:41:14 +08:00
pengtao
beed5ec33c 新增周报脚本 2019-11-19 19:25:21 +08:00
pengtao
dbafe755e9 新增周报脚本 2019-11-19 19:20:43 +08:00
pengtao
9934c35166 tag 分析从SS 直接抽取 2019-11-14 14:21:20 +08:00
pengtao
7b831a3278 数据仅一天有记录的,暂不上报 2019-11-14 11:55:47 +08:00
pengtao
0560d433c2 数据仅一天有记录的,暂不上报 2019-11-14 11:54:46 +08:00
pengtao
2a549e6776 数据仅一天有记录的,暂不上报 2019-11-14 10:57:32 +08:00
pengtao
8d766deea2 数据仅一天有记录的,暂不上报 2019-11-14 10:56:53 +08:00
pengtao
f9ad9ce1d6 数据仅一天有记录的,暂不上报 2019-11-14 10:54:44 +08:00
pengtao
6ec7598b12 数据仅一天有记录的,暂不上报 2019-11-14 10:52:06 +08:00
pengtao
2594588c2c 数据仅一天有记录的,暂不上报 2019-11-14 10:49:13 +08:00
pengtao
1d452b0029 数据仅一天有记录的,暂不上报 2019-11-14 10:48:13 +08:00
pengtao
46ef171fe3 数据仅一天有记录的,暂不上报 2019-11-14 10:36:00 +08:00
pengtao
a44f761ed2 数据仅一天有记录的,暂不上报 2019-11-14 10:29:58 +08:00
pengtao
4d24889ad0 数据仅一天有记录的,暂不上报 2019-11-14 10:28:23 +08:00
pengtao
a87215adb6 调整变化统计的正负关系 2019-11-13 14:24:36 +08:00
pengtao
d3092d3906 调整变化统计的正负关系 2019-11-13 14:24:04 +08:00
pengtao
ee62267f3d 调整变化统计的正负关系 2019-11-13 14:22:53 +08:00
pengtao
caf646636e 调整变化统计的正负关系 2019-11-13 14:03:45 +08:00
pengtao
82cfaa3544 add tags field 2019-11-13 11:13:30 +08:00
pengtao
0920b6b313 add tags field 2019-11-12 14:48:18 +08:00
pengtao
5b1110397d add tags field 2019-11-12 14:45:26 +08:00
pengtao
dc09577d96 add tags field 2019-11-12 14:44:59 +08:00
pengtao
7bb840061a add tags field 2019-11-12 14:23:11 +08:00
pengtao
d4039661f3 add tags field 2019-11-12 14:21:42 +08:00
pengtao
5501f49f3d add tags field 2019-11-12 14:18:51 +08:00
root
93aab7ac1c a 2019-11-12 14:15:01 +08:00
root
1f1fce9b52 remove somebody 2019-11-12 13:59:34 +08:00
pengtao
0fe6d0757d add tags field 2019-11-12 13:52:30 +08:00
pengtao
6fd545c4db add tags field 2019-11-11 11:28:02 +08:00
pengtao
ae01af1bd0 add tags field 2019-11-11 11:21:39 +08:00
pengtao
b453abc94e add tags field 2019-11-08 16:27:10 +08:00
pengtao
43d30c724c add tags field 2019-11-08 16:23:49 +08:00
pengtao
e1e6581979 add tags field 2019-11-08 15:30:28 +08:00
pengtao
c56313d7cc add tags field 2019-11-08 15:28:50 +08:00
pengtao
424ee95d56 add tags field 2019-11-08 15:09:13 +08:00
pengtao
000b76af1b add tags field 2019-11-08 15:06:22 +08:00
pengtao
c886e2fd3a add tags field 2019-11-08 15:04:51 +08:00
pengtao
1ac2b6c3cf add tags field 2019-11-08 15:01:23 +08:00
pengtao
c20749c2ec add tags field 2019-11-06 16:02:07 +08:00
pengtao
bf55ed09a7 add tags field 2019-11-06 15:38:21 +08:00
pengtao
25267f44ff add tags field 2019-11-06 14:35:33 +08:00
pengtao
61779400df add tags field 2019-11-06 14:20:42 +08:00
pengtao
4fc5007b66 add tags field 2019-11-06 14:19:41 +08:00
pengtao
43e2aadfd2 add tags field 2019-11-04 11:31:40 +08:00
pengtao
4c7c9a310f add tags field 2019-11-04 11:30:49 +08:00
pengtao
fb425f4157 add tags field 2019-11-04 11:22:56 +08:00
pengtao
78eba472f8 add tags field 2019-11-04 11:19:37 +08:00
pengtao
87a2cb092f add tags field 2019-11-04 11:17:42 +08:00
root
44c6ef76c7 a 2019-11-04 11:16:08 +08:00
pengtao
614c8650a1 add tags field 2019-11-04 11:13:12 +08:00
pengtao
c579a233ba add tags field 2019-11-01 14:14:27 +08:00
pengtao
cf38ac3335 游戏日报 grafana->png sendmail 2019-11-01 10:51:04 +08:00
pengtao
52d25a9d8b 游戏日报 grafana->png sendmail 2019-10-31 17:03:37 +08:00
pengtao
2202fd5a7a 游戏日报 grafana->png sendmail 2019-10-31 16:52:15 +08:00
pengtao
69194c34d0 游戏日报 grafana->png sendmail 2019-10-31 16:48:33 +08:00
pengtao
f2a905d8bc 游戏日报 grafana->png sendmail 2019-10-31 16:42:33 +08:00
pengtao
50ae91ee50 游戏日报 grafana->png sendmail 2019-10-31 16:42:13 +08:00
pengtao
e9e49bbfce 游戏日报 grafana->png sendmail 2019-10-31 16:39:55 +08:00
pengtao
4a73d93d59 游戏日报 grafana->png sendmail 2019-10-31 16:37:32 +08:00
pengtao
2a8efc04d4 游戏日报 grafana->png sendmail 2019-10-31 16:34:31 +08:00
pengtao
4c61543339 游戏日报 grafana->png sendmail 2019-10-31 16:31:46 +08:00
pengtao
0fcff40ade 游戏日报 grafana->png sendmail 2019-10-31 16:30:41 +08:00
pengtao
b177dc1ca6 游戏日报 grafana->png sendmail 2019-10-31 16:13:46 +08:00
pengtao
c728585682 游戏日报 grafana->png sendmail 2019-10-31 16:11:50 +08:00
pengtao
8c70aae3c0 游戏日报 grafana->png sendmail 2019-10-31 16:10:55 +08:00
pengtao
e8478d97d6 游戏日报 grafana->png sendmail 2019-10-31 16:00:17 +08:00
pengtao
91243c4081 游戏日报 grafana->png sendmail 2019-10-31 15:58:16 +08:00
pengtao
d659787e77 游戏日报 grafana->png sendmail 2019-10-31 15:57:58 +08:00
pengtao
69358808f5 游戏日报触发脚本 2019-10-28 14:51:29 +08:00
pengtao
50787c3e82 游戏日报触发脚本 2019-10-28 14:49:55 +08:00
pengtao
53f30e137c 游戏日报触发脚本 2019-10-28 14:47:45 +08:00
pengtao
11e68a1ea2 游戏日报触发脚本 2019-10-28 14:38:04 +08:00
pengtao
00eeaf6960 游戏日报触发脚本 2019-10-28 14:36:09 +08:00
pengtao
ab099049e5 游戏日报触发脚本 2019-10-28 14:31:32 +08:00
pengtao
54a304cd62 游戏日报触发脚本 2019-10-28 14:21:24 +08:00
pengtao
5efa62deeb 游戏日报触发脚本 2019-10-28 14:15:37 +08:00
pengtao
5815400602 卖量数据fix 字段 2019-10-28 11:30:14 +08:00
pengtao
f98ea0a492 卖量数据添加状态判断 2019-10-28 11:24:39 +08:00
pengtao
2b793ec295 添加广告显示状态判定 2019-10-28 11:18:07 +08:00
pengtao
da10c363eb 添加广告显示状态判定 2019-10-28 11:13:24 +08:00
pengtao
a212e485db 添加广告显示状态判定 2019-10-28 10:59:11 +08:00
pengtao
a1fa34427b remove fromappid = '' 2019-10-24 17:06:57 +08:00
pengtao
e92b3aa649 remove fromappid = '' 2019-10-24 16:59:59 +08:00
pengtao
c79411bbd2 remove fromappid = '' 2019-10-24 16:58:27 +08:00
pengtao
f765da9249 remove fromappid = '' 2019-10-24 16:08:49 +08:00
pengtao
7d671f73d3 remove fromappid = '' 2019-10-24 16:05:40 +08:00
pengtao
2a92d4a60b 修改fromappid 获得逻辑 2019-10-24 15:54:42 +08:00
pengtao
ac20ee46d1 修改fromappid 获得逻辑 2019-10-24 15:51:27 +08:00
pengtao
399671cb98 修改fromappid 获得逻辑 2019-10-24 15:49:28 +08:00
pengtao
e4d80b094b 修改fromappid 获得逻辑 2019-10-24 15:41:53 +08:00
pengtao
debc5f8158 修改fromappid 获得逻辑 2019-10-24 15:11:55 +08:00
pengtao
7935c061a4 修改fromappid 获得逻辑 2019-10-24 15:09:23 +08:00
pengtao
24888296a7 修改fromappid 获得逻辑 2019-10-24 15:06:37 +08:00
pengtao
a4a75bc628 传递日期参数 2019-10-24 14:43:38 +08:00
pengtao
d96abe48ee 传递日期参数 2019-10-24 14:18:53 +08:00
pengtao
1aaa4c4bf7 传递日期参数 2019-10-24 11:24:30 +08:00
pengtao
f76f43a1f2 传递日期参数 2019-10-24 11:19:29 +08:00
pengtao
403c9856c3 传递日期参数 2019-10-24 11:16:08 +08:00
pengtao
046f113fad 传递日期参数 2019-10-24 11:15:52 +08:00
pengtao
4c90896f5d 传递日期参数 2019-10-24 11:14:37 +08:00
pengtao
9202ff768e 传递日期参数 2019-10-24 10:32:32 +08:00
pengtao
826e5379cb 传递日期参数 2019-10-24 10:25:57 +08:00
pengtao
a5f8571754 传递日期参数 2019-10-24 10:24:21 +08:00
pengtao
ee47c16a73 传递日期参数 2019-10-24 10:15:11 +08:00
pengtao
8f0766e825 传递日期参数 2019-10-24 10:09:00 +08:00
pengtao
618805291b 传递日期参数 2019-10-24 10:02:41 +08:00
pengtao
e289ee258f 传递日期参数 2019-10-24 09:56:25 +08:00
pengtao
4708da9d18 传递日期参数 2019-10-24 09:52:18 +08:00
pengtao
fd96fef694 传递日期参数 2019-10-23 20:39:16 +08:00
pengtao
f8942ff31b 传递日期参数 2019-10-23 20:35:43 +08:00
pengtao
a546122cf1 传递日期参数 2019-10-23 20:24:50 +08:00
pengtao
959b7c3a03 传递日期参数 2019-10-23 20:23:02 +08:00
pengtao
d4f65af156 Merge remote-tracking branch 'origin/master' 2019-10-23 20:19:43 +08:00
pengtao
a843ed463a 传递日期参数 2019-10-23 20:19:20 +08:00
27 changed files with 1694 additions and 81 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
.idea/datacollect.iml
.idea/dataSources.local.xml
.idea/dataSources.xml
.idea/encodings.xml
.idea/misc.xml
.idea/modules.xml
.idea/vcs.xml
.idea/workspace.xml
.idea/codeStyles/codeStyleConfig.xml
.idea/dataSources/ded72fb6-4b0d-46ce-b5cb-564dd047df87.xml

38
1.py Normal file
View File

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
import requests
class MpGameList:
def __init__(self):
self.mp_games_url = "https://mp.kingsome.cn/api/open/games/list"
def get_gameid(self):
r = requests.get(self.mp_games_url)
all = []
if r.status_code == requests.codes.ok:
try:
data = r.json().get("gameList")
except Exception:
print(f"get data failed!")
try:
for line in data: # {"game":"一起织娃娃","game_id":8002,"game_name":"knitting","platform":"weixin","platform_id":6001,"platform_name":"微信"}
if line.get("platform") == "test":
continue
else:
temp = {}
temp['name_cn'] = line.get("game", "")
temp['game_id'] = line.get("game_id", 0)
temp['platform_name'] = line.get("platform_name", "")
temp['platform_id'] = line.get("platform_id", 0)
all.append(temp)
except Exception:
print(f"split data with{r.json()} failed")
return all
else:
return None
if __name__ == "__main__":
mm = MpGameList()
data = mm.get_gameid()
print(data)

View File

@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
import datetime
import sys
import requests
from ops.plog import define_logger
import logging
define_logger("/data/logs/ops/daily_report_cron.log")
log = logging.getLogger(__name__)
def get_url(url):
r = requests.get(url)
if r.status_code == requests.codes.ok:
return True
else:
log.error(f"connect {url} failed, {r.content}", exc_info=True)
return False
def main():
try:
project = sys.argv[1]
except Exception:
log.error("PLS inpit project!")
raise Exception("PLS inpit project")
if len(sys.argv) != 3:
times = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
else:
times = sys.argv[2]
if str(project) == '2001':
url = f"http://10.10.3.10:6700/send-dailyreport?day={times}&project=2001"
else:
url = f"http://10.10.3.10:6700/send-dailyreport?day={times}"
if get_url(url):
log.info(f"connect {project} {times} success!")
else:
log.error(f"send report {project} {times} failed!")
if __name__ == "__main__":
main()

View File

@ -10,6 +10,13 @@ from collections import defaultdict
from ops.plog import define_logger from ops.plog import define_logger
import logging import logging
import datetime import datetime
import requests
from ops.mmysql import MysqlBase
import copy
import json
from collections import defaultdict
db_conf = {'user': 'mytga', 'pswd': 'gzVwh4HGR68G', 'host': '10.10.3.5', 'db': 'external_data'}
define_logger("/data/logs/ops/daily_report.log") define_logger("/data/logs/ops/daily_report.log")
import pdb import pdb
@ -27,9 +34,13 @@ app.config['MAIL_PASSWORD'] = 'bX8cfBAyj9MBqH22'
mail = Mail(app) mail = Mail(app)
recipients = ["pengtao@kingsome.cn","yulixing@kingsome.cn"] #recipients_mini = ["pengtao@kingsome.cn"]
recipients_mini = ["pengtao@kingsome.cn", "tangwenjing@kingsome.cn", "yuexin@kingsome.cn", "yuetao@kingsome.cn"]
recipients_2001 = ["pengtao@kingsome.cn", "chenliang@kingsome.cn", "yuexin@kingsome.cn", "yuetao@kingsome.cn"]
#recipients_2001 = ["pengtao@kingsome.cn"]
# FROMAPPID_CN = {"wxdb103a128e118619": "拯救熊猫泡泡", "wxc137c93eedeab6f2": "爆冰达人"} # FROMAPPID_CN = {"wxdb103a128e118619": "拯救熊猫泡泡", "wxc137c93eedeab6f2": "爆冰达人"}
@ -60,32 +71,65 @@ def send_async_email(app, msg):
@app.route('/send-dailyreport') @app.route('/send-dailyreport')
def send_dailyreport(): def send_dailyreport():
title = "主题" title = "OPS报表"
msg = Message(title, sender=sender, recipients=recipients)
day = request.args.get('day') day = request.args.get('day')
project = request.args.get('project') or 'mini_games' project = request.args.get('project') or 'mini_games'
if not (project and day): if not (project and day):
return jsonify("PLS input arfs") return jsonify("PLS input arfs")
if str(project) == '2001':
recipients = recipients_2001
else:
recipients = recipients_mini
msg = Message(title, sender=sender, recipients=recipients)
rp = Report(day, project) rp = Report(day, project)
data = rp.run() data = rp.run()
print(data) print(data)
#data[day] = day #data[day] = day
msg.subject = f"{project}_{day}_数据"
msg.html = render_template('report.html', data=data, day=day)
thread = Thread(target=send_async_email, args=[app, msg]) if str(project) == '2001':
thread.start() msg.subject = f"求生之岛_{day}_游戏日报"
else:
msg.subject = f"休闲游戏_{day}_游戏日报"
if data:
msg.html = render_template('report.html', data=data, day=day)
thread = Thread(target=send_async_email, args=[app, msg])
thread.start()
return jsonify("邮件发送成功")
else:
return jsonify("get Data Failed!")
@app.route('/send-tapweekly')
def send_tapweekly():
title = "TAP周报"
day = request.args.get('day')
recipients = ["pengtao@kingsome.cn", "yuexin@kingsome.cn", "yuetao@kingsome.cn"]
msg = Message(title, sender=sender, recipients=recipients)
twr = TapWeeklyReport(day)
data, tags = twr.run()
# print(data)
# data[day] = day
msg.subject = f"TAPTAP_{day}_游戏周报"
if data:
msg.html = render_template('tap_weekly.html', data=data, day=day, tags=tags)
thread = Thread(target=send_async_email, args=[app, msg])
thread.start()
return jsonify("邮件发送成功")
else:
return jsonify("get Data Failed!")
return jsonify("邮件发送成功")
class Report: class Report:
def __init__(self, day, project): def __init__(self, day, project):
self.day = day self.day = day
self.project = project self.project = project
self.not_minigames = (2001, 2002,2003)
def get_all_data(self, **args): def get_all_data(self, **args):
activa_sql = f"""SELECT activa_sql = f"""SELECT
@ -94,7 +138,7 @@ class Report:
v_event_{args['suffix']} v_event_{args['suffix']}
where where
gameid='{args['gameid']}' gameid='{args['gameid']}'
and channel='{args['channelid']}' and "channel"='{args['channelid']}'
and "$part_event"='event_11_1' and "$part_event"='event_11_1'
and "$part_date"='{self.day}'""" and "$part_date"='{self.day}'"""
@ -104,7 +148,7 @@ class Report:
v_event_{args['suffix']} v_event_{args['suffix']}
where where
gameid='{args['gameid']}' gameid='{args['gameid']}'
and channel='{args['channelid']}' and "channel"='{args['channelid']}'
and "$part_event"='event_11_1' and "$part_event"='event_11_1'
and account_register_date between timestamp'{self.day} 00:00:00' and timestamp'{self.day} 23:59:59'""" and account_register_date between timestamp'{self.day} 00:00:00' and timestamp'{self.day} 23:59:59'"""
@ -115,7 +159,7 @@ class Report:
where where
"$part_event"='event_11_10' "$part_event"='event_11_10'
and gameid='{args['gameid']}' and gameid='{args['gameid']}'
and channel='{args['channelid']}' and "channel"='{args['channelid']}'
and "$part_event"='event_11_1' and "$part_event"='event_11_1'
and "$part_date"='{self.day}'""" and "$part_date"='{self.day}'"""
@ -133,10 +177,11 @@ class Report:
timeonlie_sql = f"""SELECT timeonlie_sql = f"""SELECT
sum(cast(online_duration as int)) sum(cast(online_duration as int))
FROM FROM
v_event_19 v_event_{args['suffix']}
where where
"$part_event"='event_21_2' "$part_event"='event_21_2'
and gameid='{args['gameid']}' and gameid='{args['gameid']}'
and "channel"='{args['channelid']}'
and "$part_date"='{self.day}' """ and "$part_date"='{self.day}' """
ad_101_sql = f"""SELECT ad_101_sql = f"""SELECT
@ -148,6 +193,7 @@ class Report:
and gameid='{args['gameid']}' and gameid='{args['gameid']}'
and "channel"='{args['channelid']}' and "channel"='{args['channelid']}'
AND activity_id=101 AND activity_id=101
AND adv_id_state='0'
and "$part_date"='{self.day}' """ and "$part_date"='{self.day}' """
ad_1_sql = f"""SELECT ad_1_sql = f"""SELECT
@ -159,6 +205,7 @@ class Report:
and gameid='{args['gameid']}' and gameid='{args['gameid']}'
and "channel"='{args['channelid']}' and "channel"='{args['channelid']}'
AND activity_id=1 AND activity_id=1
AND adv_id_state='0'
and "$part_date"='{self.day}' """ and "$part_date"='{self.day}' """
ad_201_sql = f"""SELECT ad_201_sql = f"""SELECT
@ -171,24 +218,47 @@ class Report:
and "channel"='{args['channelid']}' and "channel"='{args['channelid']}'
AND activity_id=201 AND activity_id=201
and "$part_date"='{self.day}' """ and "$part_date"='{self.day}' """
jumpout_sql = f"""SELECT if args['gameid'] not in self.not_minigames:
count(distinct "#account_id") jumpout_sql = f"""SELECT
FROM count(distinct "#account_id")
v_event_19 FROM
where v_event_{args['suffix']}
"$part_event"='event_1_4' where
"$part_event"='event_1_4'
and gameid='{args['gameid']}'
and "channel"='{args['channelid']}'
and "$part_date"='{self.day}'
and "jump_result"=1 """
else:
jumpout_sql = f"""SELECT
count(distinct "#account_id")
FROM
v_event_{args['suffix']}
where
"$part_event"='event_11_31'
and gameid='{args['gameid']}'
and "channel"='{args['channelid']}'
and "$part_date"='{self.day}' and "$part_date"='{self.day}'
and "jump_result"=1 """ and "button_name" like 'wx%_success'"""
try: try:
activa = args['tga'].get_data(activa_sql)[0][0] activa = args['tga'].get_data(activa_sql)[0][0] or 0
new = args['tga'].get_data(new_sql)[0][0] new = args['tga'].get_data(new_sql)[0][0] or 0
share = args['tga'].get_data(share_sql)[0][0] share = args['tga'].get_data(share_sql)[0][0] or 0
timeonlie = args['tga'].get_data(timeonlie_sql)[0][0] or 0 jumpout = args['tga'].get_data(jumpout_sql)[0][0] or 0
ad_101 = args['tga'].get_data(ad_101_sql)[0][0] if activa:
ad_1 = args['tga'].get_data(ad_1_sql)[0][0] timeonlie = round(int(args['tga'].get_data(timeonlie_sql)[0][0] or 0) / activa, 2)
ad_201 = args['tga'].get_data(ad_201_sql)[0][0] jump_per = round((100 * jumpout) / activa, 2)
jumpout = args['tga'].get_data(jumpout_sql)[0][0] else:
jump_per = round((100 * jumpout) / activa, 2) timeonlie = 0
jump_per = 0
if args['gameid'] not in self.not_minigames:
ad_101 = args['tga'].get_data(ad_101_sql)[0][0] or 0
ad_1 = args['tga'].get_data(ad_1_sql)[0][0] or 0
ad_201 = args['tga'].get_data(ad_201_sql)[0][0] or 0
else:
ad_101 = ad_1 = ad_201 = 0
return [activa, new, share, timeonlie, ad_1, ad_101, ad_201, jump_per] return [activa, new, share, timeonlie, ad_1, ad_101, ad_201, jump_per]
except Exception: except Exception:
log.error(f"get data from tga failed ,{args['gameid']}", exc_info=True) log.error(f"get data from tga failed ,{args['gameid']}", exc_info=True)
@ -202,7 +272,7 @@ class Report:
v_event_{args['suffix']} v_event_{args['suffix']}
where where
gameid='{args['gameid']}' gameid='{args['gameid']}'
and channel='{args['channelid']}' and "channel"='{args['channelid']}'
and "$part_event"='event_11_1' and "$part_event"='event_11_1'
and "$part_date"='{self.day}' and "$part_date"='{self.day}'
and from_appid='{args['fromappid']}'""" and from_appid='{args['fromappid']}'"""
@ -212,7 +282,7 @@ class Report:
v_event_{args['suffix']} v_event_{args['suffix']}
where where
gameid='{args['gameid']}' gameid='{args['gameid']}'
and channel='{args['channelid']}' and "channel"='{args['channelid']}'
and "$part_event"='event_11_1' and "$part_event"='event_11_1'
and account_register_date between timestamp'{self.day} 00:00:00' and timestamp'{self.day} 23:59:59' and account_register_date between timestamp'{self.day} 00:00:00' and timestamp'{self.day} 23:59:59'
and from_appid='{args['fromappid']}' """ and from_appid='{args['fromappid']}' """
@ -224,7 +294,7 @@ class Report:
where where
"$part_event"='event_11_10' "$part_event"='event_11_10'
and gameid='{args['gameid']}' and gameid='{args['gameid']}'
and channel='{args['channelid']}' and "channel"='{args['channelid']}'
and "$part_event"='event_11_1' and "$part_event"='event_11_1'
and "$part_date"='{self.day}' and "$part_date"='{self.day}'
and from_appid='{args['fromappid']}' """ and from_appid='{args['fromappid']}' """
@ -236,7 +306,7 @@ class Report:
where where
"$part_event"='event_11_11' "$part_event"='event_11_11'
and gameid='{args['gameid']}' and gameid='{args['gameid']}'
and channel='{args['channelid']}' and "channel"='{args['channelid']}'
and "$part_event"='event_11_1' and "$part_event"='event_11_1'
and "$part_date"='{self.day}' and "$part_date"='{self.day}'
and from_appid='{args['fromappid']}' """ and from_appid='{args['fromappid']}' """
@ -249,49 +319,154 @@ class Report:
k = 0 k = 0
else: else:
k = round((100 * byshare / (activa - byshare)), 2) k = round((100 * byshare / (activa - byshare)), 2)
return (args['fromappid'], args['fromappid_cn'], activa, new, share, k) return (args['fromappid_cn'], activa, new, share, k)
except Exception: except Exception:
log.error(f"collect input failed {args['gameid']} {args['fromappid']}", exc_info=True) log.error(f"collect input failed {args['gameid']} {args['fromappid']}", exc_info=True)
return None return None
def get_output_fromappid(self, **args): def get_output_fromappid(self, **args):
jump_sql = f"""SELECT if args['gameid'] not in self.not_minigames:
count("#account_id"),count(distinct "#account_id") jump_sql = f"""SELECT
FROM count("#account_id"),count(distinct "#account_id")
v_event_19 FROM
where v_event_{args['suffix']}
"$part_event"='event_1_4' where
and "$part_date"='{self.day}' "$part_event"='event_1_4'
and "jump_appid"='{args['fromappid']}' and gameid='{args['gameid']}'
and "jump_result"=1 """ and "channel"='{args['channelid']}'
and "$part_date"='{self.day}'
and "jump_appid"='{args['fromappid']}'
and "jump_result"=1 """
else:
jump_sql = f"""SELECT
count("#account_id"),count(distinct "#account_id")
FROM
v_event_{args['suffix']}
where
"$part_event"='event_11_31'
and gameid='{args['gameid']}'
and "channel"='{args['channelid']}'
and "$part_date"='{self.day}'
and "button_name"='{args['fromappid']}_success'"""
data = args['tga'].get_data(jump_sql) data = args['tga'].get_data(jump_sql)
if data: if data:
try: try:
jump_num, jump_pre = data[0] jump_num, jump_pre = data[0]
return (args['fromappid'], args['fromappid_cn'], jump_num, jump_pre) return (args['fromappid_cn'], jump_num, jump_pre)
except Exception: except Exception:
log.error(f"get data from output by {args['gameid']} {args['fromappid']} failed", exc_info=True) log.error(f"get data from output by {args['gameid']} {args['fromappid']} failed", exc_info=True)
return None return None
else: else:
return None return None
def get_args_cn(self):
gameids_cn = dict()
channel_cn = dict()
url = "http://10.10.5.4:2333/api/open/games/list"
r = requests.get(url)
if r.status_code == requests.codes.ok:
data = r.json().get('gameList')
for line in data:
try:
gameids_cn[line.get('game_id')] = line.get('game')
channel_cn[line.get('platform_id')] = line.get('platform_name')
except Exception:
log.error(f"split {line} failed!", exc_info=True)
return (gameids_cn, channel_cn)
else:
return None
def get_ss_input_fromappid(self, args):
if args['gameid'] not in self.not_minigames:
sql = f"""select distinct from_appid FROM
v_event_{args['suffix']}
where
"$part_event"='event_11_1'
and gameid='{args['gameid']}'
and "channel"='{args['channelid']}'
and "$part_date"='{self.day}'"""
data = args['tga'].get_data(sql)
input_fromappids = list()
if data:
try:
for line in data:
if line and line[0] != '':
input_fromappids.append(line[0])
except Exception:
log.error(f"split {line} error", exc_info=True)
return input_fromappids
else:
return None
def get_ss_output_fromappid(self, args):
output_fromappids = list()
if args['gameid'] not in self.not_minigames:
sql = f"""select distinct jump_appid FROM
v_event_{args['suffix']}
where
"$part_event"='event_1_4'
and gameid='{args['gameid']}'
and "channel"='{args['channelid']}'
and "jump_result"=1
and "$part_date"='{self.day}'"""
data = args['tga'].get_data(sql)
if data:
try:
for line in data:
if line and line[0] != '':
output_fromappids.append(line[0].split('_success')[0])
except Exception:
log.error(f"split {line} error", exc_info=True)
return output_fromappids
else:
sql = f"""select distinct button_name FROM
v_event_{args['suffix']}
where
"$part_event"='event_11_31'
and gameid='{args['gameid']}'
and "channel"='{args['channelid']}'
and "$part_date"='{self.day}'
and button_name like 'wx%_success'"""
data = args['tga'].get_data(sql)
if data:
try:
for line in data:
if line and line[0] != '':
output_fromappids.append(line[0])
except Exception:
log.error(f"split {line} error", exc_info=True)
return output_fromappids
def run(self): def run(self):
if self.project == 'mini_games': if self.project == 'mini_games':
parms = [(1004, 6001), (1011, 6001), (1001, 6001)] parms = [(1004, 6001), (1011, 6001), (1001, 6001), (1013, 6001), (1016, 6001), (2020, 6001), (2021, 6001),
else: (2022, 6001)]
elif self.project == '2001':
parms = [(2001, 6001), (2002, 6001)] parms = [(2001, 6001), (2002, 6001)]
else:
return None
cn = self.get_args_cn()
if not cn:
return None
else:
game_cn, chanel_cn = cn
data = list() data = list()
for item in parms: for item in parms:
args = {} args = {}
args['gameid'], args['channelid'] = item args['gameid'], args['channelid'] = item
# key = f"{args['gameid']}#{args['channelid']}"
temp = {} temp = {}
temp['gameid'] = args['gameid'] temp['gameid'] = game_cn.get(args['gameid'], None)
temp['channelid'] = args['channelid'] temp['channelid'] = chanel_cn.get(args['channelid'], None)
temp['input'] = defaultdict(list) temp['input'] = defaultdict(list)
temp['output'] = defaultdict(list) temp['output'] = defaultdict(list)
temp['input'] = [] temp['input'] = []
@ -305,29 +480,163 @@ class Report:
args['tga'] = tga args['tga'] = tga
temp['all'] = self.get_all_data(**args) temp['all'] = self.get_all_data(**args)
mp = MpInterface() if temp['all'] and self.project == '2001':
fromappids = mp.get_fromappid_cn(args['gameid'], args['channelid']) ss_input_fromappids = self.get_ss_input_fromappid(args)
f_keys = fromappids.keys() ss_output_fromappids = self.get_ss_output_fromappid(args)
if not f_keys:
continue mp = MpInterface()
for f_key in f_keys: fromappids = mp.get_fromappid_cn(args['gameid'], args['channelid'])
args['fromappid'] = f_key # log.info(f"1={fromappids} 2={ss_input_fromappids} 3={ss_output_fromappids}")
args['fromappid_cn'] = fromappids.get(f_key, None) or "未知" if fromappids and ss_input_fromappids:
temp['input'].append(self.get_input_fromappid(**args)) for item in ss_input_fromappids:
temp['output'].append(self.get_output_fromappid(**args)) args['fromappid'] = item
print(temp) args['fromappid_cn'] = fromappids.get(item, None) or item
data.append(temp) temp['input'].append(self.get_input_fromappid(**args))
if fromappids and ss_output_fromappids:
for item in ss_output_fromappids:
if args['gameid'] in self.not_minigames:
args['fromappid'] = item.split('_success')[0]
else:
args['fromappid'] = item
args['fromappid_cn'] = fromappids.get(item.split('_success')[0], None) or item
temp['output'].append(self.get_output_fromappid(**args))
print(f"current_data={temp}")
try:
if temp['all'][0] > 5:
data.append(temp)
except Exception:
log.error(f"get active user failed,{temp['all']}", exc_info=True)
elif temp['all'] and self.project == 'mini_games':
try:
if temp['all'][0] > 5:
data.append(temp)
except Exception:
log.error(f"get active user failed,{temp['all']}", exc_info=True)
else:
log.error(f"someting was wrong with {temp}")
return data return data
class TapWeeklyReport:
def __init__(self, day):
self.day = day
self.db_conn = MysqlBase(**db_conf)
self.limit = 20
self.all_type = {"download": {"name": "热门榜", "row": ["download"]}, "new": {"name": "新品榜", "row": ["download"]},
"reserve": {"name": "预约榜", "row": ["reserve"]}, "sell": {"name": "热卖榜", "row": ["sell"]},
"played": {"name": "热玩榜", "row": ["download"]}}
self.base_head = ["diff_order","title", "order", "min_order", "max_order","watch"]
self.base_end = [ "score", "tags"]
self.row_cn = { "title": "游戏名称", "order": "当前排名", "min_order": "最高排名", "max_order": "最低排名",
"diff_order": "排名变动", "watch":"关注数","download": "下载数", "reserve": "预约数", "sell": "购买数",
"score": "评分","tags": "游戏标签"}
def struct_data(self, data):
r_data = list()
for key in self.all_type.keys():
try:
data_key = data.get(key, [])
temp = {}
temp["name"] = self.all_type.get(key).get("name")
rows = self.base_head + self.all_type.get(key).get("row") + self.base_end
temp["row_name"] = []
for k in rows:
temp["row_name"].append(self.row_cn.get(k))
temp["row_data"] = []
for line in data_key[0]:
tt = {}
# (30802, '死战骑士团', 56, 56, 56, 0, 5.1, '付费,策略,单机', 8984, 0, 7794, 0, 272, 34)
tt['gameid'], tt['title'], tt['order'], tt['min_order'], tt['max_order'], tt['diff_order'],tt['score'], tt['tags'], tt['watch'], tt['download'], tt['sell'], tt['reserve'], tt['review'],tt['topic'] = line
new_tt = copy.deepcopy(tt)
for item in tt.keys():
if item not in rows:
new_tt.pop(item)
ttt = list()
for k in rows:
ttt.append(new_tt.get(k))
temp["row_data"].append(ttt)
r_data.append(temp)
except Exception:
log.error(f"struct data with {line} Failed", exc_info=True)
new_tags = dict()
if r_data:
new_tags = self.collect_tags(r_data)
return r_data, new_tags
def collect_tags(self, data):
row_tags = dict()
new_data=dict()
for line in data:
try:
data_type = line.get("name")
row_tags[data_type]={}
for items in line.get("row_data"):
for tag in items[-1].split(','):
row_tags[data_type][tag] = row_tags[data_type].get(tag, 0) + 1
new_tags = sorted(row_tags[data_type].items(), key=lambda d: d[1], reverse=True)
new_data[data_type] = list()
for i in range(0, 3):
new_data[data_type].append(new_tags[i])
except Exception:
log.error(f"collect tags failed with {line}", exc_info=True)
return new_data
def build(self):
# weekly_day = json.dumps(self.get_weekly_days()).strip('[]')
# tap_types = ("new", "download", "reserve", "sell", "played")
all_data = defaultdict(list)
for tap_type in self.all_type.keys():
sql = f"""select
gameid,
title as "名称",
`order` as "当前排名",
min_order as "最高排名",
max_order as "最低排名",
diff_order as "排名变动",
score as "评分",
tags as "游戏标签",
watch as "关注数",
download as "下载数",
sell as "购买数",
reserve as "预约数",
review as "评论数",
topic as "话题"
from
tap_weekly
where
catename='{tap_type}'
and date = '{self.day}'
and order_posi = 1
order by
`diff_order` desc limit {self.limit};"""
data = self.db_conn.query(sql)
#log.info(f"sql={sql}")
if data:
all_data[tap_type].append(data)
return all_data
def run(self):
data = self.build()
r_data, tags = self.struct_data(data)
#print(f"rr={r_data},tags={tags}")
return r_data, tags
def main(): def main():
day = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d') day = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
project = 'mini_games' project = 'mini_games'
cc = Report(day, project) cc = Report(day, project)
data = cc.run() data = cc.run()
print(data) #print(data)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -0,0 +1,66 @@
# -*- coding: utf-8 -*-
import requests
import pdb
# Head = {"Accept": "application/json",
# "Authorization": "Bearer eyJrIjoiczVHc2lpWkw1a2Jsb0RxeXNKaEhPczQ3QzNtSUtRNHIiLCJuIjoibWlsZXMiLCJpZCI6MX0="}
# url = "http://grafana.kingsome.cn/d/oN5uGwEik/kingsomeren-shu-qu-xian?orgId=1&from=1572226084591&to=1572247684591"
import os, stat
import urllib.request
from datetime import datetime, date, time, timedelta
import time as Time
# 获取七日前0点与今日0点的时间戳
def last_seven_day():
midnight = datetime.combine(date.today(), time.min)
yesterday_mid = midnight - timedelta(days=7) # 想要此前几天的,就改这个参数
epoch = datetime.utcfromtimestamp(0)
midnight = midnight - timedelta(seconds=1)
midnight = int((midnight - epoch).total_seconds() * 1000.0)
yesterday_mid = int((yesterday_mid - epoch).total_seconds() * 1000.0)
return str(yesterday_mid), str(midnight)
# 下载指定的dashboard
def download_db():
# 组装url跑代码之前现在浏览器试试
dbuid = "p5aRo00Wz"
# dbuid = "mI5F3QnWk"
grafana_server = "https://grafana-test.kingsome.cn"
# grafana_server = "http://grafana.kingsome.cn"
# url = f"""{grafana_server}/render/d/{dbuid}?from{last_seven_day()[0]}&to={last_seven_day()[
# 1]}&&var-datasource=xxx&width=1500&height=700&tz=UTC%2B08%3A00"""
url="http://grafana.kingsome.cn/render/d-solo/hzR9LcoZk/taptappai-ming-fen-xi?orgId=1&from=1572413361151&to=1572434961151&var-gameid=10056&var-date=All&var-catename=download&panelId=2&width=1000&height=1500&tz=Asia%2FShanghai"
# url="http://grafana.kingsome.cn/d/e2zRV1emk/shu-ju-yan-shi?orgId=1&from=1571715151698&to=1572319951698&var-name=All&var-date=All"
# header = {"Accept": "application/json", "Content-Type": "application/json",
# "Authorization": "Bearer eyJrIjoiczVHc2lpWkw1a2Jsb0RxeXNKaEhPczQ3QzNtSUtRNHIiLCJuIjoibWlsZXMiLCJpZCI6MX0="}
keys="eyJrIjoiczVHc2lpWkw1a2Jsb0RxeXNKaEhPczQ3QzNtSUtRNHIiLCJuIjoibWlsZXMiLCJpZCI6MX0="
#keys = "eyJrIjoiWGFFMXp4YTlaODFHUFpVQmxBcHVDWUZNSUFvb2doNDEiLCJuIjoidGVzdCIsImlkIjoyfQ=="
header = {"Accept": "application/json", "Content-Type": "application/json", "Authorization": f"Bearer {keys}"}
print(url)
request = urllib.request.Request(url, headers=header)
#pdb.set_trace()
try:
# 访问并下载面板图
response = urllib.request.urlopen(request)
time_now = int(Time.time())
time_local = Time.localtime(time_now)
dt = Time.strftime("%Y-%m-%d", time_local)
img_name = f"img{dt}.png"
filename = img_name
# print(response.getcode())
if (int(response.getcode()) == 200):
with open(filename, "wb") as f:
f.write(response.read())
return filename
else:
return "failed"
except:
return "failed"
if __name__ == "__main__":
download_db()

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
</head>
<body>
<h1>tttt</h1>
<img src="{{ user_image }}" alt="test Image">
<img src="https://stackabuse.com/assets/images/logo-dropbox.svg?v=47a80c143d" alt="222">
</body>
</html>

View File

@ -106,13 +106,13 @@
<table> <table>
<thead> <thead>
<tr> <tr>
<th>活跃</th> <th>活跃人数</th>
<th>新增</th> <th>新增人数</th>
<th>分享</th> <th>分享人数</th>
<th>时长</th> <th>人均时长(秒)</th>
<th>屏显示</th> <th>频广告展示次数</th>
<th>banner显示</th> <th>banner展示次数</th>
<th>插屏显示</th> <th>插屏广告展示次数</th>
<th>导出率</th> <th>导出率</th>
</tr> </tr>
</thead> </thead>
@ -126,17 +126,18 @@
</table> </table>
</div> </div>
{% if line.input %}
<div class="panel"> <div class="panel">
<h2>导入数据</h2> <h2>买量数据</h2>
<table> <table>
<thead> <thead>
<tr> <tr>
<!--('wxdb103a128e118619', '拯救熊猫泡泡', 2, 1, 0, 0.0)--> <!--('wxdb103a128e118619', '拯救熊猫泡泡', 2, 1, 0, 0.0)-->
<th>渠道ID</th>
<th>游戏名称</th> <th>游戏名称</th>
<th>活跃</th> <th>活跃人数</th>
<th>新增</th> <th>新增人数</th>
<th>分享</th> <th>分享人数</th>
<th>K值</th> <th>K值</th>
</tr> </tr>
</thead> </thead>
@ -151,13 +152,14 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{% endif %}
{% if line.output %}
<div class="panel"> <div class="panel">
<h2>导出数据:</h2> <h2>卖量数据:</h2>
<table> <table>
<thead> <thead>
<tr> <tr>
<th>渠道ID</th>
<th>跳转目标</th> <th>跳转目标</th>
<th>跳转次数</th> <th>跳转次数</th>
<th>跳转人数</th> <th>跳转人数</th>
@ -174,6 +176,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{% endif %}
</div> </div>
{% endfor %} {% endfor %}
</body> </body>

View File

@ -0,0 +1,152 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>TAP周报</title>
<style>
* {
margin: 0;
padding: 0;
}
html {
background-color: #fdfdfd;
}
body {
padding: 0 20px;
color: #333;
}
h1.title {
margin: 30px 0 20px;
font-size: 32px !important;
font-weight: 500;
text-align: center !important;
}
.date {
margin: 20px 0;
text-align: center;
}
.section {
border-top: 1px dashed #ccc;
}
.info {
margin: 60px 0 30px;
font-size: 16px;
text-align: center;
}
.info > span {
margin-right: 20px;
}
.info .gameid,
.info .channelid {
font-weight: 700;
}
.panel {
width: 80%;
margin: 0 auto 60px;
}
.panel h2 {
height: 36px;
padding-left: 16px;
margin: 20px 0;
font-size: 24px;
font-weight: 500;
border-left: #909090 3px solid;
}
.panel table {
/* width: 100%; */
line-height: 2;
text-align: left;
border-collapse: collapse;
}
.panel table th {
font-weight: 500;
color: #909090;
}
.panel table td,
.panel table th {
padding: 0 16px;
border-bottom: 1px solid #f0f0f0;
font-size: 16px;
}
.panel table tr:nth-child(even) {
background-color: #f3f3f3;
}
.panel .part {
margin-bottom: 16px;
}
.panel .part .title {
margin-bottom: 8px;
font-weight: 700;
}
.panel .part .content span:nth-child(2n) {
margin-right: 16px;
}
</style>
</head>
<body>
<h1 class="title">TAPTAP数据周报· OPS</h1>
<p class="date">{{ day }}</p>
<div class="section">
<div class="info">
<span>{{ "各榜单游戏类别分布(前三)" }}</span>
</div>
<div class="panel">
{% for key in tags.keys() %}
<div class="part">
<div class="title">{{ key }}</div>
<div class="content">
{% for one in tags.get(key) %}
<span>{{ one[0] }}</span>[
<span>{{ one[1] }}</span>]
{% endfor %}
</div>
</div>
{% endfor %}
</div>
</div>
{% for key in data %}
<div class="section">
<div class="info">
<span>报表类型:<span class="gameid">{{ key.get('name') }}</span></span>
</div>
<div class="panel">
<table>
<thead>
<tr>
{% for row_name_one in key.get('row_name') %}
<td>{{ row_name_one }}</td>
{% endfor %}
</tr>
</thead>
<tbody>
{% for one_data in key.get('row_data') %}
<tr>
{% for item in one_data %}
<td>{{ item }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endfor %}
</div>
</body>
</html>

11
daily_report/test01.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<iframe src="http://grafana.kingsome.cn/d/hzR9LcoZk/taptappai-ming-fen-xi?from=1572224823823&to=1572246423823&orgId=1&var-gameid=10491&var-gameid=10498&var-gameid=12492&var-date=2019-10-27&var-date=2019-10-26&var-date=2019-10-25&var-date=2019-10-24&var-date=2019-10-23&var-date=2019-10-22&var-date=2019-10-21&var-catename=download"
width="650" height="300" frameborder="0"></iframe>
</body>
</html>

View File

@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
from flask import Flask, render_template, jsonify,url_for
# from flask_mail import Mail, Message
import os
from threading import Thread
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.header import Header
import smtplib
PEOPLE_FOLDER = os.path.join(os.path.abspath('.'), '/static/images')
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = PEOPLE_FOLDER
sender = "ops@kingsome.cn"
app.config['MAIL_SERVER'] = 'smtp.exmail.qq.com'
app.config['MAIL_PORT'] = '465'
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USE_TLS'] = False ## 默认就是 false, 加上警示自己
app.config['MAIL_USERNAME'] = sender
app.config['MAIL_PASSWORD'] = 'bX8cfBAyj9MBqH22'
# mail = Mail(app)
recipients = ['pengtao@kingsome.cn']
def add_img(file, imgid, msg):
fp = open(file, 'rb')
img = MIMEImage(fp.read())
fp.close()
img.add_header("Content-ID", f'<{imgid}>')
html = f"<html><body><br><img src=\"cid:{imgid}\" border=\"1\"</br></body></html>"
content = MIMEText(html, 'html', 'utf-8')
msg.attach(content)
msg.attach(img)
return msg
@app.route('/')
def show_index():
title = "test报表"
# msg = Message(title, sender=sender, recipients=recipients)
msg = MIMEMultipart('related')
msg['from'] = sender
mail_to = "pengtao@kingsome.cn"
msg['Subject'] = Header(title, 'utf-8')
full_filename = os.path.join(app.config['UPLOAD_FOLDER'], 'img2019-10-31.png')
msg = add_img(full_filename, 'Active', msg)
msgText = MIMEText("邮件正文", 'html', 'utf-8')
msg.attach(msgText)
mail_user = sender
mail_passwd = 'bX8cfBAyj9MBqH22'
try:
smtObj = smtplib.SMTP_SSL()
smtObj.connect('smtp.exmail.qq.com', 465)
smtObj.login(mail_user, mail_passwd)
COMMSAPACE = ','
smtObj.sendmail(sender, mail_to.split(','), msg.as_string())
except smtplib.SMTPException:
return jsonify("Error")
# full_filename = url_for("static",filename= 'images/img2019-10-31.png')
# filename = "/root/miles/test/static/images/img2019-10-31.png"
# import base64
# img_file = open(filename, 'rb')
# base64_data = base64.b64encode(img_file.read())
# html = f"""<img src="data: image/png;base64, {base64_data}" alt="image1">"""
#
# # print(full_filename)
# msg.html = render_template('index.html', user_image=full_filename)
# msg.html += html
return jsonify("邮件发送成功")
if __name__ == "__main__":
# show_index() # main() #
app.run(host='0.0.0.0', port=9700, debug=False)

View File

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
import datetime
import sys
import requests
from ops.plog import define_logger
import logging
define_logger("/data/logs/ops/weekly_report_cron.log")
log = logging.getLogger(__name__)
def get_url(url):
r = requests.get(url)
if r.status_code == requests.codes.ok:
return True
else:
log.error(f"connect {url} failed, {r.content}", exc_info=True)
return False
def main():
if len(sys.argv) == 2:
times = sys.argv[2]
else:
times = (datetime.date.today() - datetime.timedelta(days=2)).strftime('%Y-%m-%d')
url = f"http://10.10.3.10:6700/send-tapweekly?day={times}"
if get_url(url):
log.info(f"connect {times} success!")
else:
log.error(f"send report {times} failed!")
if __name__ == "__main__":
main()

Binary file not shown.

Binary file not shown.

View File

@ -18,3 +18,33 @@ class MpInterface:
key = "fromappid_cn" key = "fromappid_cn"
url = f"{self.base_url}channelid={channelid}&gameid={gameid}&key={key}" url = f"{self.base_url}channelid={channelid}&gameid={gameid}&key={key}"
return self.get_data(url) return self.get_data(url)
class MpGameList:
def __init__(self):
self.mp_games_url = "https://mp.kingsome.cn/api/open/games/list"
def get_gameid(self):
r = requests.get(self.mp_games_url)
all = []
if r.status_code == requests.codes.ok:
try:
data = r.json().get("gameList")
except Exception:
print(f"get data failed!")
try:
for line in data: # {"game":"一起织娃娃","game_id":8002,"game_name":"knitting","platform":"weixin","platform_id":6001,"platform_name":"微信"}
if line.get("platform") == "test":
continue
else:
temp = {}
temp['name_cn'] = line.get("game", "")
temp['game_id'] = line.get("game_id", 0)
temp['platform_name'] = line.get("platform_name", "")
temp['platform_id'] = line.get("platform_id", 0)
all.append(temp)
except Exception:
print(f"split data with{r.json()} failed")
return all
else:
return None

View File

@ -11,7 +11,7 @@ def define_logger(filename="/data/logs/aa.log",debug=True):
logger.setLevel(logging.ERROR) logger.setLevel(logging.ERROR)
# 设置输出格式 # 设置输出格式
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') formatter = logging.Formatter('%(asctime)s - %(name)s - %(lineno)s - %(levelname)s - %(message)s')
# 设置日志文件处理器 # 设置日志文件处理器
fh = logging.FileHandler(filename) fh = logging.FileHandler(filename)

82
taptap/tap2influxdb.py Normal file
View File

@ -0,0 +1,82 @@
# -*- coding: utf-8 -*-
import pdb
from influxdb import InfluxDBClient, exceptions
from ops.mtga import FromTga
from ops.plog import define_logger
import logging
import datetime
import sys
define_logger("/data/logs/ops/tap2influxdb.log")
log = logging.getLogger(__name__)
class TAP2Influx:
def __init__(self, day):
url = "http://10.10.3.17:8992/querySql"
api_secret = "n9H4R32ZcjtSeN89ljCY6ESzTmOlnwwnOB3r4YsggnP5M1AXLtKtiS4sS1KKLOEQ"
self.tga = FromTga(url=url, token=api_secret)
self.day = day
self.influx = InfluxDBClient('10.10.3.19', '8086', 'miles', 'aspect', 'tap_data')
self.measurement = "tapdata"
def get_tga_data(self):
sql = f"""SELECT
gameid,
catename,
cate,
title,
score,
"order",
tags,
reserve,
watch,
download,
sell,
review,
topic,
"#event_time"
FROM
v_event_25
WHERE
"$part_date"='{self.day}' """
body = list()
data = self.tga.get_data(sql)
if data:
try:
for line in data:
gameid, catename, cate, title, score, order, tag, reserve, watch, download, sell, review, topic, createdat = line
tags = {"gameid": int(gameid), "catename": catename}
fields = {"title": title, "score": score, "tag": tag, "reserve": reserve, "watch": watch,
"download": download, "sell": sell, "review": review, "topic": topic, "cate": cate,
"catedat": createdat, "order": order}
temp = {"measurement": self.measurement, "tags": tags, "fields": fields}
body.append(temp)
except Exception:
log.error(f"split data failed ,{line}", exc_info=True)
try:
#print(body)
self.influx.write_points(body)
except Exception:
log.error(f"write 2 influx failed,data={body}", exc_info=True)
else:
print(f"sql={sql}")
def run(self):
self.get_tga_data()
if __name__ == "__main__":
if len(sys.argv) == 2:
try:
d = sys.argv[1]
except Exception:
log.error(f"split args with start time failed ,args={d}", exc_info=True)
raise Exception(f"split args with start time failed ,args={d}")
else:
d = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
tt = TAP2Influx(d)
tt.run()

73
taptap/tap_split_tags.py Normal file
View File

@ -0,0 +1,73 @@
# -*- coding: utf-8 -*-
from ops.mmysql import MysqlBase
from ops.mtga import FromTga
from ops.plog import define_logger
import logging
import datetime
import pdb
define_logger("/data/logs/ops/split_tags.log")
log = logging.getLogger(__name__)
db_conf = {'user': 'mytga', 'pswd': 'gzVwh4HGR68G', 'host': '10.10.3.5', 'db': 'external_data'}
class SplitTapTags:
def __init__(self, day):
self.db_conn = MysqlBase(**db_conf)
self.url = "http://10.10.3.17:8992/querySql"
self.api_secret = "n9H4R32ZcjtSeN89ljCY6ESzTmOlnwwnOB3r4YsggnP5M1AXLtKtiS4sS1KKLOEQ"
self.tga = FromTga(url=self.url, token=self.api_secret)
self.type = ['new', 'reserve']
self.day = day
def get_data(self):
all = dict()
for types in self.type:
all[types] = {}
sql = f"""SELECT tags FROM v_event_25 where catename='{types}' and "$part_date"='{self.day}' """
tags = self.tga.get_data(sql)
if tags:
for line in tags:
if line:
try:
for item in line[0].split(","):
all[types][item] = all[types].get(item, 0) + 1
except Exception:
log.error(f"split {line} failed!", exc_info=True)
#print(all)
return all
def write2db(self, data):
db_data = {}
tables_name = "tap_tags_counts"
for key in data.keys():
for k in data[key]:
db_data['type'] = key
db_data['name'] = k
db_data['date'] = self.day
db_data['nums'] = data[key][k]
try:
self.db_conn.insert(tables_name, db_data)
except Exception:
log.error(f"insert {db_data} failed!", exc_info=True)
def run(self):
data = self.get_data()
#pdb.set_trace()
self.write2db(data)
def main():
import sys
if len(sys.argv) == 2:
day = sys.argv[1]
else:
day = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
stt = SplitTapTags(day)
stt.run()
if __name__ == "__main__":
main()

158
taptap/tap_weekly_mail.py Normal file
View File

@ -0,0 +1,158 @@
# -*- coding: utf-8 -*-
from ops.mmysql import MysqlBase
from ops.plog import define_logger
import logging
import datetime
import json
from collections import defaultdict
import pdb
import sys
define_logger("/data/logs/ops/tap_weekly.log")
log = logging.getLogger(__name__)
db_conf = {'user': 'mytga', 'pswd': 'gzVwh4HGR68G', 'host': '10.10.3.5', 'db': 'external_data'}
class TapWeeklyReport:
def __init__(self, day):
self.day = day
self.db_conn = MysqlBase(**db_conf)
self.limit = 20
def get_weekly_days(self):
weekly_days = []
for i in range(0, 7):
current_day = (datetime.datetime.strptime(self.day, '%Y-%m-%d') - datetime.timedelta(days=i)).strftime(
'%Y-%m-%d')
weekly_days.append(current_day)
return weekly_days
def build(self):
weekly_day = json.dumps(self.get_weekly_days()).strip('[]')
tap_types = ("new", "download", "reserve", "sell", "played")
all_data = dict()
for tap_type in tap_types:
sql = f"""select
gameid,
min(`order`), max(`order`)
from
taptap_collect
where
catename='{tap_type}'
and date in ({weekly_day})
group by
gameid
"""
data = self.db_conn.query(sql)
if data:
try:
for line in data:
gameid, min_order, max_order = line
all_data.setdefault(gameid, {}).setdefault(tap_type, {})["min_order"] = min_order
all_data.setdefault(gameid, {}).setdefault(tap_type, {})["max_order"] = max_order
# all_data[tap_type].append(data)
except Exception:
log.error(f"get {tap_type} min/max order failed!", exc_info=True)
sql02 = f"""select gameid,title,score,tags,`order`,watch,download,sell,review,reserve,topic from
taptap_collect
where
catename='{tap_type}'
and date ='{self.day}'
"""
data02 = self.db_conn.query(sql02)
if data02:
try:
for line in data02:
gameid, title, score, tags, order, watch, download, sell, review, reserve, topic = line
all_data.setdefault(gameid, {}).setdefault(tap_type, {})["title"] = title
all_data.setdefault(gameid, {}).setdefault(tap_type, {})["score"] = score
all_data.setdefault(gameid, {}).setdefault(tap_type, {})["tags"] = ",".join(
tags.split(',')[0:3])
all_data.setdefault(gameid, {}).setdefault(tap_type, {})["order"] = order
all_data.setdefault(gameid, {}).setdefault(tap_type, {})["watch"] = watch
all_data.setdefault(gameid, {}).setdefault(tap_type, {})["download"] = download
all_data.setdefault(gameid, {}).setdefault(tap_type, {})["sell"] = sell
all_data.setdefault(gameid, {}).setdefault(tap_type, {})["review"] = review
all_data.setdefault(gameid, {}).setdefault(tap_type, {})["reserve"] = reserve
all_data.setdefault(gameid, {}).setdefault(tap_type, {})["topic"] = topic
except Exception:
log.error(f"get {tap_type} details failed!", exc_info=True)
# check data if not title ,get from last day
for gameid in all_data.keys():
for catename in all_data[gameid]:
if not all_data[gameid][catename].get('title'):
all_data[gameid][catename]["title"], all_data[gameid][catename]["score"], \
all_data[gameid][catename]["tags"], all_data[gameid][catename]["order"], all_data[gameid][catename][
"watch"], all_data[gameid][catename]["download"], all_data[gameid][catename]["sell"], \
all_data[gameid][catename]["review"], all_data[gameid][catename]["reserve"], \
all_data[gameid][catename]["topic"] = self.get_last_data(gameid, catename)
if not all_data[gameid][catename]["title"]:
all_data[gameid].pop(catename)
else:
all_data[gameid][catename]["tags"] = ",".join(
all_data[gameid][catename]["tags"].split(',')[0:3])
return all_data
def get_last_data(self, gameid, catename):
sql = f"""select title,score,tags,`order`,watch,download,sell,review,reserve,topic from
taptap_collect
where
catename='{catename}'
and gameid ={gameid} order by date desc limit 1 """
data = self.db_conn.query(sql)
try:
title, score, tags, order, watch, download, sell, review, reserve, topic = data[0]
except Exception:
title, score, tags, order, watch, download, sell, review, reserve, topic = None
log.error(f"get last info data failed", exc_info=True)
return (title, score, tags, order, watch, download, sell, review, reserve, topic)
def run(self):
table_name = "tap_weekly"
all = dict()
data = self.build()
for gameid in data.keys():
for catename in data[gameid]:
all['gameid'] = gameid
all['catename'] = catename
all['min_order'] = data[gameid][catename].get('min_order', 0)
all['max_order'] = data[gameid][catename].get('max_order', 0)
all['diff_order'] = int(all['max_order']) - int(all['min_order'])
all['title'] = data[gameid][catename].get('title', "")
all['score'] = data[gameid][catename].get('score', 0)
all['tags'] = data[gameid][catename].get('tags', "")
all['order'] = data[gameid][catename].get('order', 0)
all['watch'] = data[gameid][catename].get('watch', 0)
all['download'] = data[gameid][catename].get('download', 0)
all['sell'] = data[gameid][catename].get('sell', 0)
all['review'] = data[gameid][catename].get('review', 0)
all['reserve'] = data[gameid][catename].get('reserve', 0)
all['topic'] = data[gameid][catename].get('topic', 0)
all['date'] = self.day
if abs(all['order'] - all['min_order']) <= abs(all['order'] - all['max_order']):
all["order_posi"] = 1
else:
all["order_posi"] = 0
self.db_conn.insert(table_name, all)
print(all)
def main():
if len(sys.argv) == 2:
day = sys.argv[1]
else:
day = (datetime.date.today() - datetime.timedelta(days=2)).strftime('%Y-%m-%d')
twr = TapWeeklyReport(day)
twr.run()
if __name__ == "__main__":
main()

115
taptap/taptap_daily_tags.py Normal file
View File

@ -0,0 +1,115 @@
# -*- coding: utf-8 -*-
from ops.mtga import FromTga
from ops.plog import define_logger
from ops.mmysql import MysqlBase
import logging
import datetime
import pdb
import sys
import json
define_logger("/data/logs/ops/taptap_daily_taps.log")
log = logging.getLogger(__name__)
import sys
class TapTapReport:
def __init__(self, day):
self.db_conf = {'user': 'mytga', 'pswd': 'gzVwh4HGR68G', 'host': '10.10.3.5', 'db': 'external_data'}
self.url = "http://10.10.3.17:8992/querySql"
self.api_secret = "n9H4R32ZcjtSeN89ljCY6ESzTmOlnwwnOB3r4YsggnP5M1AXLtKtiS4sS1KKLOEQ"
self.tga = FromTga(url=self.url, token=self.api_secret)
self.day = day # self.bday = (datetime.datetime.strptime(self.day, "%Y-%m-%d") - datetime.timedelta(days=1)).strftime( # '%Y-%m-%d')
def get_tags(self):
sql = f"""SELECT
catename,
tags,
"order"
FROM
v_event_25
where
"$part_date"='{self.day}'"""
data = self.tga.get_data(sql)
tags_data = {}
if data:
for line in data:
try:
catename, tags, order = line
if catename not in tags_data.keys():
tags_data[catename] = {}
temp_dict = tags_data.get(catename, {})
#print(f"base temp={temp_dict}")
for tag in tags.split(","):
temp_dict[tag] = temp_dict.get(tag, 0) + self.order2score(order)
#print(f"old={tags_data},type={catename},new={temp_dict}")
# pdb.set_trace()
tags_data[catename].update(temp_dict)
except Exception:
log.error(f"split {line} failed", exc_info=True)
return tags_data
def write2db(self, data):
table_name = "taptap_tags_daily"
db = MysqlBase(**self.db_conf)
for catename in data.keys():
temp = {}
temp["catename"] = catename
temp["day"] = self.day
for name in data.get(catename).keys():
temp["score"] = data.get(catename)[name]
temp["type"] = name
db.insert(table_name, temp)
def order2score(self, order):
try:
order_int = int(order)
if order_int <= 10 and order_int >= 1:
return 5
elif order_int > 10 and order_int <= 50:
return 3
elif order_int <= 200:
return 2
else:
return 1
except Exception:
log.error(f"PLS check order={order} ", exc_info=True)
return 0
def get_days(bengin):
all_days = []
# end = (datetime.date.today() - datetime.timedelta(days=2)).strftime('%Y-%m-%d')
for i in range(1, 100):
n = i + 2
next_day = (datetime.date.today() - datetime.timedelta(days=n)).strftime('%Y-%m-%d')
if next_day == bengin:
return all_days
else:
all_days.append(next_day)
def main():
if len(sys.argv) == 2:
day = sys.argv[1]
else:
day = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
# begin = "2019-10-15"
# all_days = get_days(begin)
# print(all_days)
tap = TapTapReport(day)
data = tap.get_tags()
tap.write2db(data)
if __name__ == "__main__":
main()

View File

@ -0,0 +1,153 @@
# -*- coding: utf-8 -*-
from ops.mtga import FromTga
from ops.plog import define_logger
from ops.mmysql import MysqlBase
import logging
import datetime
import pdb
import sys
from bson.objectid import ObjectId
import json
define_logger("/data/logs/ops/taptap_collect.log")
log = logging.getLogger(__name__)
import sys
class TapTapReport:
def __init__(self, day):
self.db_conf = {'user': 'mytga', 'pswd': 'gzVwh4HGR68G', 'host': '10.10.3.5', 'db': 'external_data'}
self.url = "http://10.10.3.17:8992/querySql"
self.api_secret = "n9H4R32ZcjtSeN89ljCY6ESzTmOlnwwnOB3r4YsggnP5M1AXLtKtiS4sS1KKLOEQ"
self.tga = FromTga(url=self.url, token=self.api_secret)
self.day = day
self.bday = (datetime.datetime.strptime(self.day, "%Y-%m-%d") - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
self.bbday = (datetime.datetime.strptime(self.day, "%Y-%m-%d") - datetime.timedelta(days=2)).strftime(
'%Y-%m-%d')
def clear_noice(self):
# 结合前后2天的数据清理diff_order >200的数据
pass
def diff_item(self, all, item):
for key in self.gameid_info_1.keys():
all.setdefault(key, {})['gameid'] = key.split("#")[0]
all[key]['catename'] = key.split('#')[1]
all[key]['date'] = self.bday
diff_key = f"diff_{item}"
if self.gameid_info_1.get(key, {}).get(item, -1)>=0 and self.gameid_info_2.get(key, {}).get(item, -1)>=0:
all[key][diff_key] = int(self.gameid_info_1[key].get(item, 0) - self.gameid_info_2[key].get(item, 0))
all.setdefault(key, {})[item] = self.gameid_info_1[key].get(item, 0)
elif self.gameid_info_1.get(key, {}).get(item, -1)>=0 and self.gameid_info_0.get(key, {}).get(item, -1)>=0:
all[key][diff_key] = "新晋榜"
all.setdefault(key, {})[item] = self.gameid_info_1[key].get(item, 0)
elif self.gameid_info_0.get(key, {}).get(item, -1)>=0 and self.gameid_info_2.get(key, {}).get(item, -1)>=0:
all[key][diff_key] = int(self.gameid_info_0[key].get(item, 0) - self.gameid_info_2[key].get(item, 0))
all.setdefault(key, {})[item] = self.gameid_info_0[key].get(item, 0)
else:
pass
# 三天中有2天没数据写入日志不予处理 # log.error(f"{all[key]} {item} {self.gameid_info_0.get(key,{})} {self.gameid_info_1.get(key,
# {})} {self.gameid_info_2.get(key,{})} missing 2 days data")
if item == "order":
try:
all[key][diff_key] = -int(all[key][diff_key])
except:
pass
return all
def build_report(self):
mydb = MysqlBase(**self.db_conf)
all = dict()
gameid_order = dict()
# get 最新的gameid info数据
self.gameid_info_0 = self.get_gameid_info(self.day)
self.gameid_info_1 = self.get_gameid_info(self.bday)
self.gameid_info_2 = self.get_gameid_info(self.bbday)
for key in self.gameid_info_1.keys():
all.setdefault(key, {})['gameid'] = key.split("#")[0]
all[key]['catename'] = key.split('#')[1]
all[key]['date'] = self.bday
try:
# ("order", "watch", "download", "sell", "review", "reserve", "topic")
all[key]['title'] = self.gameid_info_1.get(key,{}).get('title', None) or self.gameid_info_0.get(key,{}).get('title',None) or self.gameid_info_2.get(key,{}).get('title', None)
all[key]['cate'] = self.gameid_info_1.get(key,{}).get('cate', None) or self.gameid_info_0.get(key,{}).get('cate',None) or self.gameid_info_2.get(key,{}).get('cate', None)
all[key]['score'] = self.gameid_info_1.get(key,{}).get('score', 0) or self.gameid_info_0.get(key,{}).get('score',0) or self.gameid_info_2.get(key,{}).get('score', 0)
all[key]['tags'] = self.gameid_info_1.get(key,{}).get('tags', None) or self.gameid_info_0.get(key,{}).get('tags',None) or self.gameid_info_2.get(key,{}).get('tags', None)
except Exception:
log.error(f"split {all[key]} error ", exc_info=True)
items = ("order", "watch", "download", "sell", "review", "reserve", "topic")
for item in items:
all = self.diff_item(all, item)
i = 0
for line in all.values():
try:
#print(line)
if line.get("order", 0) >= 1:
mydb.insert("taptap_collect", line)
i += 1
except Exception:
log.error(f"install 2 db failed ,values={line}", exc_info=True)
log.info(f"insert {i} 2 mysql!")
def get_gameid_info(self, day):
all_data = dict()
sql = f"""SELECT
gameid,
catename,
title,
cate,
"order",
topic,
score,
reserve,
watch,
download,
sell,
review ,
tags
FROM
v_event_25
where
"$part_date"='{day}'"""
data = self.tga.get_data(sql)
if data:
for line in data:
try:
gameid, catename, title, cate, order, topic, score, reserve, watch, download, sell, review, tags = line
key = f"{str(int(gameid))}#{catename}"
all_data.setdefault(key, {})["key"] = key
all_data.setdefault(key, {})["catename"] = catename
all_data.setdefault(key, {})["title"] = title
all_data.setdefault(key, {})["cate"] = cate
all_data.setdefault(key, {})["order"] = order
all_data.setdefault(key, {})["topic"] = topic
all_data.setdefault(key, {})["score"] = score
all_data.setdefault(key, {})["reserve"] = reserve
all_data.setdefault(key, {})["watch"] = watch
all_data.setdefault(key, {})["download"] = download
all_data.setdefault(key, {})["sell"] = sell
all_data.setdefault(key, {})["review"] = review
all_data.setdefault(key, {})["tags"] = tags
except Exception:
log.error(f"split {line} failed", exc_info=True)
return all_data
def main():
if len(sys.argv) == 2:
day = sys.argv[1]
else:
day = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
tap = TapTapReport(day)
tap.build_report()
if __name__ == "__main__":
main()

View File

@ -22,6 +22,10 @@ class TapTapReport:
self.day = day self.day = day
self.bday = (datetime.datetime.strptime(self.day, "%Y-%m-%d") - datetime.timedelta(days=1)).strftime('%Y-%m-%d') self.bday = (datetime.datetime.strptime(self.day, "%Y-%m-%d") - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
def clear_noice(self):
pass
def build_report(self): def build_report(self):
mydb = MysqlBase(**self.db_conf) mydb = MysqlBase(**self.db_conf)
@ -51,6 +55,7 @@ class TapTapReport:
all[key]['download'] = gameid_info[key]['download'] all[key]['download'] = gameid_info[key]['download']
all[key]['sell'] = gameid_info[key]['sell'] all[key]['sell'] = gameid_info[key]['sell']
all[key]['review'] = gameid_info[key]['review'] all[key]['review'] = gameid_info[key]['review']
all[key]['tags'] = gameid_info[key]['tags']
b_game_info = self.get_gameid_info(self.bday) b_game_info = self.get_gameid_info(self.bday)
for key in all.keys(): for key in all.keys():
@ -65,6 +70,7 @@ class TapTapReport:
all[key]['download'] = b_game_info[key]['download'] all[key]['download'] = b_game_info[key]['download']
all[key]['sell'] = b_game_info[key]['sell'] all[key]['sell'] = b_game_info[key]['sell']
all[key]['review'] = b_game_info[key]['review'] all[key]['review'] = b_game_info[key]['review']
all[key]['tags'] = b_game_info[key]['tags']
except Exception: except Exception:
print(f"0={key}") print(f"0={key}")
@ -88,7 +94,8 @@ class TapTapReport:
watch, watch,
download, download,
sell, sell,
review review ,
tags
FROM FROM
v_event_25 v_event_25
where where
@ -97,7 +104,7 @@ class TapTapReport:
if data: if data:
for line in data: for line in data:
try: try:
gameid, catename, title, cate, topic, score, reserve, watch, download, sell, review = line gameid, catename, title, cate, topic, score, reserve, watch, download, sell, review, tags = line
key = f"{str(int(gameid))}#{catename}" key = f"{str(int(gameid))}#{catename}"
all_data.setdefault(key, {})["key"] = key all_data.setdefault(key, {})["key"] = key
all_data.setdefault(key, {})["catename"] = catename all_data.setdefault(key, {})["catename"] = catename
@ -110,6 +117,7 @@ class TapTapReport:
all_data.setdefault(key, {})["download"] = download all_data.setdefault(key, {})["download"] = download
all_data.setdefault(key, {})["sell"] = sell all_data.setdefault(key, {})["sell"] = sell
all_data.setdefault(key, {})["review"] = review all_data.setdefault(key, {})["review"] = review
all_data.setdefault(key, {})["tags"] = tags
except Exception: except Exception:
log.error(f"split {line} failed", exc_info=True) log.error(f"split {line} failed", exc_info=True)
return all_data return all_data

227
taptap/taptap_report_new.py Normal file
View File

@ -0,0 +1,227 @@
# -*- coding: utf-8 -*-
from ops.mtga import FromTga
from ops.plog import define_logger
from ops.mmysql import MysqlBase
import logging
import datetime
import pdb
import sys
from bson.objectid import ObjectId
import json
define_logger("/data/logs/ops/taptap_report.log")
log = logging.getLogger(__name__)
import sys
class TapTapReport:
def __init__(self, day):
self.db_conf = {'user': 'mytga', 'pswd': 'gzVwh4HGR68G', 'host': '10.10.3.5', 'db': 'external_data'}
self.url = "http://10.10.3.17:8992/querySql"
self.api_secret = "n9H4R32ZcjtSeN89ljCY6ESzTmOlnwwnOB3r4YsggnP5M1AXLtKtiS4sS1KKLOEQ"
self.tga = FromTga(url=self.url, token=self.api_secret)
self.day = day
self.bday = (datetime.datetime.strptime(self.day, "%Y-%m-%d") - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
self.bbday = (datetime.datetime.strptime(self.day, "%Y-%m-%d") - datetime.timedelta(days=2)).strftime(
'%Y-%m-%d')
def clear_noice(self):
# 结合前后2天的数据清理diff_order >200的数据
pass
def build_report(self):
mydb = MysqlBase(**self.db_conf)
all = dict()
gameid_order = dict()
# get 最新的gameid info数据
gameid_info = self.get_gameid_info(self.bday)
for item in (self.day, self.bday, self.bbday):
b_d = self.split_order_data(item)
for key in b_d:
gameid_order.setdefault(key, {}).update(b_d[key])
for key in gameid_order.keys():
all.setdefault(key, {})['gameid'] = key.split("#")[0]
all[key]['catename'] = key.split('#')[1]
all[key]['date'] = self.bday
if gameid_order[key].get(self.bday, 0) and gameid_order[key].get(self.bbday, 0) and gameid_order[key].get(
self.day, 0):
all[key]['diff_order'] = gameid_order[key].get(self.bbday, 0) - gameid_order[key].get(self.bday, 0)
all.setdefault(key, {})['current_order'] = gameid_order[key].get(self.bday, 0)
elif gameid_order[key].get(self.bday, 0) and gameid_order[key].get(self.bbday, 0):
all[key]['diff_order'] = gameid_order[key].get(self.bbday, 0) - gameid_order[key].get(self.bday, 0)
all.setdefault(key, {})['current_order'] = gameid_order[key].get(self.bday, 0)
elif gameid_order[key].get(self.bday, 0) and gameid_order[key].get(self.day, 0):
all[key]['diff_order'] = "新晋榜"
all.setdefault(key, {})['current_order'] = gameid_order[key].get(self.bday, 0)
elif gameid_order[key].get(self.bbday, 0) and gameid_order[key].get(self.day, 0):
all[key]['diff_order'] = gameid_order[key].get(self.bbday, 0) - gameid_order[key].get(self.day, 0)
all.setdefault(key, {})['current_order'] = gameid_order[key].get(self.day, 0)
else:
# 三天中有2天没数据写入日志不予处理
log.error(f"{key} missing 2 days data,{self.bday}={gameid_order[key].get(self.bday, 0)},{self.bbday}={gameid_order[key].get(self.bbday, 0)},{self.day}={gameid_order[key].get(self.day, 0)}")
for key in gameid_info.keys():
all[key]['title'] = gameid_info[key]['title']
all[key]['cate'] = gameid_info[key]['cate']
all[key]['topic'] = gameid_info[key]['topic']
all[key]['score'] = gameid_info[key]['score']
all[key]['reserve'] = gameid_info[key]['reserve']
all[key]['watch'] = gameid_info[key]['watch']
all[key]['download'] = gameid_info[key]['download']
all[key]['sell'] = gameid_info[key]['sell']
all[key]['review'] = gameid_info[key]['review']
all[key]['tags'] = gameid_info[key]['tags']
b_game_info = self.get_gameid_info(self.bbday)
n_game_info = self.get_gameid_info(self.day)
for key in all.keys():
if not all[key].get('title', None):
try:
all[key]['title'] = b_game_info.get(key,{}).get('title',None) or n_game_info.get(key,{}).get('title',None)
all[key]['cate'] = b_game_info.get(key,{}).get('cate',None) or n_game_info.get(key,{}).get('cate',None)
all[key]['topic'] = b_game_info.get(key,{}).get('topic',None) or n_game_info.get(key,{}).get('topic',None)
all[key]['score'] = b_game_info.get(key, {}).get('score', 0) or n_game_info.get(key, {}).get(
'score', 0)
all[key]['reserve'] = b_game_info.get(key, {}).get('reserve', 0) or n_game_info.get(key, {}).get(
'reserve', 0)
all[key]['watch'] = b_game_info.get(key, {}).get('watch', 0) or n_game_info.get(key, {}).get(
'watch', 0)
all[key]['download'] = b_game_info.get(key, {}).get('download', 0) or n_game_info.get(key, {}).get(
'download', 0)
all[key]['sell'] = b_game_info.get(key, {}).get('sell', 0) or n_game_info.get(key, {}).get('sell',
0)
all[key]['review'] = b_game_info.get(key, {}).get('review', 0) or n_game_info.get(key, {}).get(
'review', 0)
all[key]['tags'] = b_game_info.get(key,{}).get('tags',None) or n_game_info.get(key,{}).get('tags',None)
except Exception:
log.error(f"0={key} 1={all.get(key, 0)} 2={b_game_info.get(key, 0)} 3={n_game_info.get(key, 0)}",
exc_info=True)
for line in all.values():
try:
#print(line)
if line.get('current_order', 0) > 0:
mydb.insert("taptap_data_new", line)
else:
log.error(f"some value is zore ,{line}!")
except Exception:
log.error(f"install 2 db failed ,values={line}", exc_info=True)
def get_gameid_info(self, day):
all_data = dict()
sql = f"""SELECT
gameid,
catename,
title,
cate,
topic,
score,
reserve,
watch,
download,
sell,
review ,
tags
FROM
v_event_25
where
"$part_date"='{day}'"""
data = self.tga.get_data(sql)
if data:
for line in data:
try:
gameid, catename, title, cate, topic, score, reserve, watch, download, sell, review, tags = line
key = f"{str(int(gameid))}#{catename}"
all_data.setdefault(key, {})["key"] = key
all_data.setdefault(key, {})["catename"] = catename
all_data.setdefault(key, {})["title"] = title
all_data.setdefault(key, {})["cate"] = cate
all_data.setdefault(key, {})["topic"] = topic
all_data.setdefault(key, {})["score"] = score
all_data.setdefault(key, {})["reserve"] = reserve
all_data.setdefault(key, {})["watch"] = watch
all_data.setdefault(key, {})["download"] = download
all_data.setdefault(key, {})["sell"] = sell
all_data.setdefault(key, {})["review"] = review
all_data.setdefault(key, {})["tags"] = tags
except Exception:
log.error(f"split {line} failed", exc_info=True)
return all_data
def split_order_data(self, day):
all_data = dict()
mydb = MysqlBase(**self.db_conf)
sql = f"select gameid,catename,`order`,date from taptap_order WHERE date='{day}'"
data = mydb.query(sql)
if data:
for line in data:
try:
gameid, catename, order, date = line
key = f"{str(gameid)}#{catename}"
temp = {}
temp[date] = order
all_data[key] = temp
except Exception:
log.error(f"split line failed,values={line}", exc_info=True)
return all_data
def get_order(self):
sql = f"""
SELECT
gameid,
catename,
"order"
FROM
v_event_25
WHERE
"$part_date"='{self.day}'
"""
data = self.tga.get_data(sql)
if data:
self.order2mysql(data)
return True
else:
return False
def order2mysql(self, data):
mydb = MysqlBase(**self.db_conf)
table_name = "taptap_order"
for line in data:
temp = {}
try:
temp["gameid"], temp["catename"], temp["order"] = line
temp["date"] = self.day
mydb.insert(table_name, temp)
except Exception:
log.error(f"instert {line} 2 db failed", exc_info=True)
def main():
if len(sys.argv) == 3:
day = sys.argv[2]
methods = sys.argv[1]
else:
methods = sys.argv[1]
day = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
if not (day and methods):
raise Exception(f"PLs input day={day} methods={methods}")
tap = TapTapReport(day)
if methods == 'data':
tap.get_order()
elif methods == "report":
tap.build_report()
elif methods == 'all':
# tap.get_order()
tap.build_report()
else:
print("PLS input methods in ('data','report')")
if __name__ == "__main__":
main()