a
This commit is contained in:
parent
99dfc3f6f8
commit
8b0396ba00
@ -26,8 +26,8 @@ class TaskService:
|
|||||||
|
|
||||||
def register_scheduled_tasks(self):
|
def register_scheduled_tasks(self):
|
||||||
self.scheduler.add_job(self.hourly_pricing, 'cron', minute='35')
|
self.scheduler.add_job(self.hourly_pricing, 'cron', minute='35')
|
||||||
# every 5 hours
|
# every 5 hours on the 24th minute
|
||||||
self.scheduler.add_job(self.inventory_pricing, 'cron', hour='*/5')
|
self.scheduler.add_job(self.inventory_pricing, 'cron', hour='*/5', minute='24')
|
||||||
self.logger.info("Scheduled tasks registered.")
|
self.logger.info("Scheduled tasks registered.")
|
||||||
|
|
||||||
def hourly_pricing(self):
|
def hourly_pricing(self):
|
||||||
|
@ -7,6 +7,7 @@ from app.db.utils import db_transaction
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from uuid import uuid4 as uuid
|
from uuid import uuid4 as uuid
|
||||||
|
import json
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -159,11 +160,13 @@ class TCGPlayerAPIService:
|
|||||||
return tcgplayer_pricing.json()
|
return tcgplayer_pricing.json()
|
||||||
|
|
||||||
def save_tcgplayer_pricing_data(self, product_id: str, pricing_data: dict):
|
def save_tcgplayer_pricing_data(self, product_id: str, pricing_data: dict):
|
||||||
|
# convert to json
|
||||||
|
pricing_data_json = json.dumps(pricing_data)
|
||||||
with db_transaction(self.db):
|
with db_transaction(self.db):
|
||||||
pricing_record = APIPricing(
|
pricing_record = APIPricing(
|
||||||
id=str(uuid()),
|
id=str(uuid()),
|
||||||
product_id=product_id,
|
product_id=product_id,
|
||||||
pricing_data=str(pricing_data)
|
pricing_data=str(pricing_data_json)
|
||||||
)
|
)
|
||||||
self.db.add(pricing_record)
|
self.db.add(pricing_record)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user