新增道具 分享图的数据统计

This commit is contained in:
pengtao 2019-08-12 16:28:11 +08:00
parent a2fd4a59d4
commit 17b52f943b
4 changed files with 121 additions and 2 deletions

View File

@ -14,4 +14,4 @@ if not is_debug:
(1016, 6001, 'shop_1016'), (1016, 6001, 'shop_new_1016'), (1016, 6001, 'tap_1016'),
(1016, 6001, 'tap_new_1016'), (2001, 6001, 'tap_2001'), (2001, 6001, 'tap_new_2001'))
else:
event_list = ((1001, 6001, 'vistis_page'), (1001, 6001, 'ad_info'))
event_list = ((1001, 6001, 'items_produce'), (1001, 6001, 'items_consum'),(1001, 6001, 'share_map'))

View File

@ -45,3 +45,17 @@ def run_event_vistis_page(kwargs):
def run_event_ad_info(kwargs):
mytga = TGA_event(**kwargs)
mytga.event_ad_info()
def run_event_items_produce(kwargs):
mytga = TGA_event(**kwargs)
mytga.event_items_produce()
def run_event_items_consum(kwargs):
mytga = TGA_event(**kwargs)
mytga.event_items_consum()
def run_event_share_map(kwargs):
mytga = TGA_event(**kwargs)
mytga.event_share_map()

View File

@ -5,6 +5,8 @@ import logging
import requests
import json
from config.config import is_debug, adv_id_state, ad_type
from ops.scripts import get_activity_ids
define_logger("/data/logs/reports.log")
log = logging.getLogger(__name__)
@ -268,3 +270,86 @@ class GetFromTga:
self.write_tga_files(temp)
except Exception:
print(f"write {line} 2 tga!", exc_info=True)
def event_items_produce(self):
sql = f"""SELECT
sum(item_cnt) as item_num,
item_id,
reason ,
reason_param
FROM
v_event_19
where
gameid='{self.gameid}'
and "channel"='{self.channelid}'
and "$part_event"='event_11_8'
and "$part_date"='{self.date}'
group by
item_id,
reason,
reason_param """
out = self.tga.get_data(sql)
if out:
for line in out:
try:
temp = {}
temp['nums'], temp['item_id'], temp['reason'], temp['reason_param'] = line
self.write_tga_files(temp)
except Exception:
print(f"write {line} 2 tga failed!", exc_info=True)
def event_items_consum(self):
sql = f"""SELECT
sum(item_cnt) as item_num,
item_id,
reason ,
reason_param
FROM
v_event_{self.suffix}
where
gameid='{self.gameid}'
and "channel"='{self.channelid}'
and "$part_event"='event_11_9'
and "$part_date"='{self.date}'
group by
item_id,
reason,
reason_param """
out = self.tga.get_data(sql)
if out:
for line in out:
try:
temp = {}
temp['nums'], temp['item_id'], temp['reason'], temp['reason_param'] = line
self.write_tga_files(temp)
except Exception:
print(f"write {line} 2 tga failed!", exc_info=True)
def event_share_map(self):
activity_ids = get_activity_ids()
sql = f"""SELECT
count(1) AS num ,
count(DISTINCT "#account_id") AS u_num,
activity_id_str
FROM
v_event_19
WHERE
gameid='1001'
AND "$part_event"='event_11_10'
AND "$part_date"='2019-08-07'
GROUP BY
activity_id_str"""
out = self.tga.get_data(sql)
if out:
for line in out:
temp = {}
if line:
try:
temp['num'], temp['u_num'], temp['activity_id_str'] = line
temp['activity_id'] = activity_ids.get(temp['activity_id_str'])
self.write_tga_files(temp)
except Exception:
print(f"write {line} 2 tga failed!", exc_info=True)

20
ops/scripts.py Normal file
View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
import pymongo
def get_activity_ids():
# get data from mongodb
# mongodb://10.10.5.6:27017/garfield-production/system_dics
# {type: 'share_cfg', deleted: false}
myclient = pymongo.MongoClient("mongodb://10.10.5.6:27017/")
mydb = myclient["garfield-production"]
mycol = mydb["system_dics"]
myquery = {type: 'share_cfg', 'deleted': False}
out_area = {'key': 1, 'value': 1, '_id': 0}
all = []
for x in mycol.find(myquery, out_area):
temp = {}
a, b = x
temp[a] = b
all.append(temp)
return all