1
This commit is contained in:
parent
b84c6b7b92
commit
dbc125e626
2
main.py
2
main.py
@ -13,6 +13,7 @@ import re
|
|||||||
from pydantic import BaseModel, Field, EmailStr
|
from pydantic import BaseModel, Field, EmailStr
|
||||||
import json
|
import json
|
||||||
import pdb
|
import pdb
|
||||||
|
from scripts.get_inc_data import set_gameinfo_ext
|
||||||
# from apscheduler.events import EVENT_JOB_EXECUTED
|
# from apscheduler.events import EVENT_JOB_EXECUTED
|
||||||
# from jobs.jobs import Schedule, job_execute
|
# from jobs.jobs import Schedule, job_execute
|
||||||
# db.gameinfo.createIndex({pubDate: -1}, {background: true})
|
# db.gameinfo.createIndex({pubDate: -1}, {background: true})
|
||||||
@ -119,6 +120,7 @@ async def getgamelist(request: Request,
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
#find_args = {"is_check": 1}
|
||||||
find_args = {}
|
find_args = {}
|
||||||
# db.gameinfo.find({'$or':[{"name":/アサツグトリ/},{"subName":'abc'}]})
|
# db.gameinfo.find({'$or':[{"name":/アサツグトリ/},{"subName":'abc'}]})
|
||||||
if category:
|
if category:
|
||||||
|
@ -5,6 +5,8 @@ import requests
|
|||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import pdb
|
import pdb
|
||||||
|
# todo: getgamelist->is_check:0 get_gameext->is_check:1
|
||||||
|
# todo: finish_check: find(gamelist:{is_check:0}) get_gameext again
|
||||||
|
|
||||||
|
|
||||||
def get_log(log_path_files="/data/logs/ops/ops.log"):
|
def get_log(log_path_files="/data/logs/ops/ops.log"):
|
||||||
@ -42,6 +44,17 @@ game_price_url = "https://switch.jumpvg.com/jump/price/getAllPriceByGame?id={gam
|
|||||||
game_history_price_url = "https://switch.jumpvg.com/switch/getDiscount?appid={gameid}&platform={platformid}&zone=all"
|
game_history_price_url = "https://switch.jumpvg.com/switch/getDiscount?appid={gameid}&platform={platformid}&zone=all"
|
||||||
|
|
||||||
|
|
||||||
|
def set_gamelist_ischeck(gameid: int) -> bool:
|
||||||
|
newvlues = {"is_check": 1}
|
||||||
|
mongo_db['gameinfo'].update_one()({
|
||||||
|
'oldGameId': gameid
|
||||||
|
}, {
|
||||||
|
'$set': newvlues
|
||||||
|
},
|
||||||
|
upsert=True)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def set_gameinfo_ext(gameids: list) -> bool:
|
def set_gameinfo_ext(gameids: list) -> bool:
|
||||||
i = 0
|
i = 0
|
||||||
for line in gameids:
|
for line in gameids:
|
||||||
@ -58,6 +71,8 @@ def set_gameinfo_ext(gameids: list) -> bool:
|
|||||||
mongo_db['gameinfoext'].update_one({'oldGameId': oldGameId},
|
mongo_db['gameinfoext'].update_one({'oldGameId': oldGameId},
|
||||||
{'$set': data},
|
{'$set': data},
|
||||||
upsert=True)
|
upsert=True)
|
||||||
|
set_gamelist_ischeck(oldGameId)
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
logger.info(f"collect gameinfoext with {oldGameId}")
|
logger.info(f"collect gameinfoext with {oldGameId}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -158,13 +173,13 @@ def get_inc_gamelist() -> list:
|
|||||||
if not m_cutOff:
|
if not m_cutOff:
|
||||||
mm_cutOff = 0
|
mm_cutOff = 0
|
||||||
item['cuttime'] = 0
|
item['cuttime'] = 0
|
||||||
|
item["is_check"] = 0
|
||||||
else:
|
else:
|
||||||
# 判断是否打折,修改cuttime数值
|
# 判断是否打折,修改cuttime数值
|
||||||
mm_cutOff = m_cutOff.get('cutOff')
|
mm_cutOff = m_cutOff.get('cutOff')
|
||||||
mprice = m_cutOff.get('price')
|
mprice = m_cutOff.get('price')
|
||||||
if abs(round(price) - round(mprice)) > 1:
|
if abs(round(price) - round(mprice)) > 1:
|
||||||
|
|
||||||
|
|
||||||
temp = {}
|
temp = {}
|
||||||
temp["gameid"] = gameid
|
temp["gameid"] = gameid
|
||||||
temp["platform"] = platform
|
temp["platform"] = platform
|
||||||
@ -196,15 +211,37 @@ def get_inc_gamelist() -> list:
|
|||||||
return diff_gameid
|
return diff_gameid
|
||||||
|
|
||||||
|
|
||||||
|
# check gamelist is_check=0,get ext again
|
||||||
|
def check_gameinfoext() -> bool:
|
||||||
|
check_failed = mongo_db['gameinfo'].find({"is_check": 0}, {
|
||||||
|
"_id": 0,
|
||||||
|
"oldGameId": 1
|
||||||
|
})
|
||||||
|
set_gameinfo_ext(list(check_failed))
|
||||||
|
|
||||||
|
|
||||||
|
def update_is_check() -> bool:
|
||||||
|
ids = mongo_db['gameinfo'].find({}, {"_id": 0, "oldGameId": 1})
|
||||||
|
for id in list(ids):
|
||||||
|
check = mongo_db['gameinfoext'].find({"oldGameId": id})
|
||||||
|
if check:
|
||||||
|
logger.info(f"update {id} set is_check =1!")
|
||||||
|
set_gamelist_ischeck(id)
|
||||||
|
else:
|
||||||
|
set_gameinfo_ext([id])
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def main_handler(event, context):
|
def main_handler(event, context):
|
||||||
change_gameids = get_inc_gamelist()
|
change_gameids = get_inc_gamelist()
|
||||||
if change_gameids:
|
logger.info(f"find diff {len(change_gameids)}")
|
||||||
print(change_gameids)
|
# if change_gameids:
|
||||||
set_game_price(change_gameids)
|
# print(change_gameids)
|
||||||
time.sleep(1)
|
# set_game_price(change_gameids)
|
||||||
set_history_price(change_gameids)
|
# time.sleep(1)
|
||||||
time.sleep(1)
|
# set_history_price(change_gameids)
|
||||||
set_gameinfo_ext(change_gameids)
|
# time.sleep(1)
|
||||||
|
# set_gameinfo_ext(change_gameids)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user