Exemplo n.º 1
0
    def update_sold(skins: List[SkinOffer]):

        with db.atomic():
            SkinOffer.bulk_update(skins,
                                  fields=[
                                      SkinOffer.title, SkinOffer.sellPrice,
                                      SkinOffer.sellTime, SkinOffer.OfferID
                                  ])
Exemplo n.º 2
0
 def update_by_asset(skin: SellOffer):
     try:
         item = SkinOffer.get(SkinOffer.AssetID == skin.AssetID)
         item.OfferID = skin.OfferID
         item.sellTime = skin.sellTime
         item.sellPrice = skin.sellPrice
         item.save()
     except DoesNotExist:
         pass
Exemplo n.º 3
0
 def create_skin(item: SellOffer) -> None:
     new_skin = SkinOffer.create(title=item.title,
                                 game=item.game,
                                 AssetID=item.AssetID,
                                 buyPrice=item.buyPrice,
                                 buyTime=item.buyTime,
                                 OfferID=item.OfferID,
                                 sellTime=item.sellTime,
                                 sellPrice=item.sellPrice)
     new_skin.save()
Exemplo n.º 4
0
 def update_offer_id(skin: SellOffer):
     try:
         item = SkinOffer.get(SkinOffer.AssetID == skin.AssetID)
         item.OfferID = skin.OfferID
         item.title = skin.title
         item.fee = skin.fee
         item.sellPrice = skin.sellPrice
         # item.sell_time = skin.sell_time
         # item.sell_price = skin.sell_price
         # item.update_time = skin.update_time
         item.save()
     except DoesNotExist:
         pass
Exemplo n.º 5
0
 def delete_all():
     skins = SkinOffer.select()
     for s in skins:
         s.delete_instance()
Exemplo n.º 6
0
 def select_all() -> List[SkinOffer]:
     skins = SkinOffer.select()
     return skins
Exemplo n.º 7
0
 def select_not_sell() -> List[SellOffer]:
     skins = SkinOffer.select().where(SkinOffer.sellTime == None)
     return [SellOffer.from_orm(s) for s in skins]
Exemplo n.º 8
0
from typing import List
from datetime import datetime
from peewee import DoesNotExist

from db.models import Skin, SkinOffer, db
from api.schemas import SkinHistory, MarketOffer, SellOffer

db.connect()
Skin.create_table()
SkinOffer.create_table()
db.close()


class SelectSkin:
    @staticmethod
    def create_all_skins(items: List[SkinHistory]):
        skins = [Skin(**i.dict()) for i in items]
        with db.atomic():
            Skin.bulk_create(skins, batch_size=500)

    @staticmethod
    def skin_existence(item: MarketOffer):
        skin = Skin.select().where(Skin.title == item.title)
        if skin:
            return True
        return False

    @staticmethod
    def find_by_name(items: List[SkinHistory]):
        skins_to_update = list()
        skin_to_create = list()