174 build - поправлен кхл парсер сайта
This commit is contained in:
@@ -67,7 +67,7 @@ class KhlCareerService:
|
||||
for kind,source in groups.items():
|
||||
people=source.get('players' if kind=='players' else 'people') or []
|
||||
if not people:continue # Missing source never deletes the database archive.
|
||||
signature=hashlib.sha256(json.dumps(source_versions.get(kind) or source,ensure_ascii=False,sort_keys=True,separators=(',',':')).encode()).hexdigest()
|
||||
signature=hashlib.sha256(json.dumps({'schema': 2, 'source': source_versions.get(kind) or source},ensure_ascii=False,sort_keys=True,separators=(',',':')).encode()).hexdigest()
|
||||
state=states.get(kind)
|
||||
if state and state.source_signature==signature:continue
|
||||
existing={row.khl_id:row for row in session.scalars(select(KhlCareerRecord).where(KhlCareerRecord.kind==kind))}
|
||||
@@ -81,6 +81,12 @@ class KhlCareerService:
|
||||
'statistics':career_modes(person,stages) if kind=='players' else staff_view(person,kind),
|
||||
'source_updated_at':person.get('source_updated_at', source.get('meta',{}).get('generated_at','')),
|
||||
'source_url':f'https://www.khl.ru/{kind}/{pid}/'}
|
||||
# Keep the complete parsed record, not just career totals.
|
||||
# No database migration needed: the existing JSON payload
|
||||
# stores all season rows, grouped columns and saved matches.
|
||||
data['archive'] = {k: v for k, v in person.items() if k != 'languages'}
|
||||
if kind == 'players':
|
||||
data['stage_metadata'] = {str(sid): stages[str(sid)] for sid in (person.get('stages') or {}) if str(sid) in stages}
|
||||
payload=json.dumps(data,ensure_ascii=False,separators=(',',':'),sort_keys=True)
|
||||
fingerprint=hashlib.sha256(payload.encode()).hexdigest()
|
||||
row=existing.get(pid)
|
||||
|
||||
Reference in New Issue
Block a user