This commit is contained in:
pengtao 2019-08-19 17:35:01 +08:00
parent 4b41244947
commit 037156b882
3 changed files with 8 additions and 14 deletions

View File

@ -15,9 +15,8 @@ class Myinflux:
def _write(self, body): def _write(self, body):
try: try:
pdb.set_trace()
self.influxdb.write_points(body) self.influxdb.write_points(body)
print(f"write {body} 2 influx!") #print(f"write {body} 2 influx!")
return True return True
except exceptions.InfluxDBClientError: except exceptions.InfluxDBClientError:
log.error(f"write {body} to influx failed!", exc_info=True) log.error(f"write {body} to influx failed!", exc_info=True)

View File

@ -52,7 +52,6 @@ class RealData(GetFromTga):
data[ad_channel].update(item) data[ad_channel].update(item)
except: except:
pass pass
print(f"2 {data}")
for key in data.keys(): for key in data.keys():
body = [{"measurement": influx_meas, body = [{"measurement": influx_meas,
"tags": {"bengin": self.b_time, "end": self.e_time, "gameid": self.gameid, "type": "real_event_user", "tags": {"bengin": self.b_time, "end": self.e_time, "gameid": self.gameid, "type": "real_event_user",
@ -81,7 +80,6 @@ class RealData(GetFromTga):
out = self.tga.get_data(sql) out = self.tga.get_data(sql)
data = {} data = {}
for line in out: for line in out:
print(f"line was {line}")
try: try:
share, share_people, ad_channel = line share, share_people, ad_channel = line
@ -91,7 +89,6 @@ class RealData(GetFromTga):
data[ad_channel] = item data[ad_channel] = item
except: except:
pass pass
print(f"3 {data}")
for key in data.keys(): for key in data.keys():
body = [{"measurement": influx_meas, body = [{"measurement": influx_meas,
"tags": {"bengin": self.b_time, "end": self.e_time, "gameid": self.gameid, "type": "real_event_share", "tags": {"bengin": self.b_time, "end": self.e_time, "gameid": self.gameid, "type": "real_event_share",
@ -104,13 +101,11 @@ class RealData(GetFromTga):
def real_event_user(kwargs): def real_event_user(kwargs):
# new_user,active_user,login_user # new_user,active_user,login_user
print(f"2 {kwargs}")
rd = RealData(**kwargs) rd = RealData(**kwargs)
rd.event_user() rd.event_user()
def real_event_share(kwargs): def real_event_share(kwargs):
# share_by_people,share_nums # share_by_people,share_nums
print(f"3 {kwargs}")
rd = RealData(**kwargs) rd = RealData(**kwargs)
rd.event_share() rd.event_share()

View File

@ -61,10 +61,10 @@ def simple_work(line):
if __name__ == "__main__": if __name__ == "__main__":
# run_tasks() run_tasks()
times = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d') # times = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
b_time = (datetime.datetime.now() - datetime.timedelta(minutes=120)).strftime('%Y-%m-%d %H:%M:%S') # b_time = (datetime.datetime.now() - datetime.timedelta(minutes=120)).strftime('%Y-%m-%d %H:%M:%S')
e_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') # e_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
for item in ((1004, 6001, 'user'), (1016, 6001, 'share')): # for item in ((1004, 6001, 'user'), (1016, 6001, 'share')):
cc = CollectGameData(times, b_time, e_time) # cc = CollectGameData(times, b_time, e_time)
cc.workflow() # cc.workflow()