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
|
||||
import json
|
||||
import pdb
|
||||
from scripts.get_inc_data import set_gameinfo_ext
|
||||
# from apscheduler.events import EVENT_JOB_EXECUTED
|
||||
# from jobs.jobs import Schedule, job_execute
|
||||
# db.gameinfo.createIndex({pubDate: -1}, {background: true})
|
||||
@ -119,6 +120,7 @@ async def getgamelist(request: Request,
|
||||
)
|
||||
|
||||
try:
|
||||
#find_args = {"is_check": 1}
|
||||
find_args = {}
|
||||
# db.gameinfo.find({'$or':[{"name":/アサツグトリ/},{"subName":'abc'}]})
|
||||
if category:
|
||||
|
@ -5,6 +5,8 @@ import requests
|
||||
import time
|
||||
import os
|
||||
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"):
|
||||
@ -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"
|
||||
|
||||
|
||||
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:
|
||||
i = 0
|
||||
for line in gameids:
|
||||
@ -58,6 +71,8 @@ def set_gameinfo_ext(gameids: list) -> bool:
|
||||
mongo_db['gameinfoext'].update_one({'oldGameId': oldGameId},
|
||||
{'$set': data},
|
||||
upsert=True)
|
||||
set_gamelist_ischeck(oldGameId)
|
||||
|
||||
i += 1
|
||||
logger.info(f"collect gameinfoext with {oldGameId}")
|
||||
except Exception as e:
|
||||
@ -158,13 +173,13 @@ def get_inc_gamelist() -> list:
|
||||
if not m_cutOff:
|
||||
mm_cutOff = 0
|
||||
item['cuttime'] = 0
|
||||
item["is_check"] = 0
|
||||
else:
|
||||
# 判断是否打折,修改cuttime数值
|
||||
mm_cutOff = m_cutOff.get('cutOff')
|
||||
mprice = m_cutOff.get('price')
|
||||
if abs(round(price) - round(mprice)) > 1:
|
||||
|
||||
|
||||
temp = {}
|
||||
temp["gameid"] = gameid
|
||||
temp["platform"] = platform
|
||||
@ -196,15 +211,37 @@ def get_inc_gamelist() -> list:
|
||||
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):
|
||||
change_gameids = get_inc_gamelist()
|
||||
if change_gameids:
|
||||
print(change_gameids)
|
||||
set_game_price(change_gameids)
|
||||
time.sleep(1)
|
||||
set_history_price(change_gameids)
|
||||
time.sleep(1)
|
||||
set_gameinfo_ext(change_gameids)
|
||||
logger.info(f"find diff {len(change_gameids)}")
|
||||
# if change_gameids:
|
||||
# print(change_gameids)
|
||||
# set_game_price(change_gameids)
|
||||
# time.sleep(1)
|
||||
# set_history_price(change_gameids)
|
||||
# time.sleep(1)
|
||||
# set_gameinfo_ext(change_gameids)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
x
Reference in New Issue
Block a user