视图过滤
This commit is contained in:
parent
da05dd532c
commit
346290412a
39
update_event_view.py.template
Normal file
39
update_event_view.py.template
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# coding:utf-8
|
||||||
|
"""
|
||||||
|
更新事件表视图
|
||||||
|
"""
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
from settings import settings
|
||||||
|
|
||||||
|
game = ''
|
||||||
|
db = settings.GAME
|
||||||
|
svrid_file = f'{game}_svrid.json'
|
||||||
|
server_list_url = f'http://gametools.legu.cc/?app=api&act=getServerList&game={game}'
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
from clickhouse_driver import Client
|
||||||
|
|
||||||
|
client = Client(**settings.CK_CONFIG)
|
||||||
|
|
||||||
|
df = pd.read_json(server_list_url)
|
||||||
|
df = df[~df['hostname'].isin(['119.3.89.14', '119.3.105.109'])]
|
||||||
|
serverid = tuple((str(i) for i in df['serverid'].to_list()))
|
||||||
|
|
||||||
|
if os.path.exists(svrid_file):
|
||||||
|
with open(svrid_file, 'r') as f:
|
||||||
|
old_svrid = json.load(f)
|
||||||
|
if set(old_svrid) == set(serverid):
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
sql = f"""drop table if exists {db}.event_view"""
|
||||||
|
res1 = client.execute(sql)
|
||||||
|
sql = f"""create view {db}.event_view as
|
||||||
|
select *
|
||||||
|
from {db}.event
|
||||||
|
where lower(`#os`) != 'windows'
|
||||||
|
and svrindex in {serverid}"""
|
||||||
|
res2 = client.execute(sql)
|
||||||
|
with open(svrid_file, 'w') as f:
|
||||||
|
json.dump(sorted(serverid), f)
|
Loading…
Reference in New Issue
Block a user