optimize local db
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
from sqlalchemy import Column, String, Integer, DateTime, func
|
||||
from sqlalchemy.orm import declarative_base
|
||||
|
||||
import definitions
|
||||
from pojo.contact_pojo import ContactPojo
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
@@ -22,23 +20,4 @@ class ContactInErrorPojo(Base):
|
||||
position: int = Column(Integer)
|
||||
error_type = Column(Integer)
|
||||
update_at = Column(DateTime, onupdate=func.now())
|
||||
create_at = Column(DateTime, default=func.now())
|
||||
|
||||
|
||||
def get_captcha_error_contact_from_contact(contact: ContactPojo, error_type: int) -> ContactInErrorPojo:
|
||||
captcha_error = ContactInErrorPojo()
|
||||
captcha_error.mail = contact.mail
|
||||
captcha_error.ccid = contact.ccid
|
||||
captcha_error.phone = contact.phone
|
||||
captcha_error.passport = contact.passport
|
||||
captcha_error.first_name = contact.first_name
|
||||
captcha_error.last_name = contact.last_name
|
||||
captcha_error.position = contact.position
|
||||
captcha_error.error_type = error_type
|
||||
return captcha_error
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
contact = ContactPojo(mail="panleici3m@gmail.com", phone_number="649114592", ccid="", position=0,
|
||||
passport_number="3322111", first_name="Lei", last_name="PAAaN")
|
||||
definitions.local_db_manager.insert_or_update(get_captcha_error_contact_from_contact(contact, ERROR_TYPE_CAPTCHA))
|
||||
create_at = Column(DateTime, default=func.now())
|
||||
@@ -1,5 +1,7 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
from pojo.captcha_error_contact_pojo import ContactInErrorPojo
|
||||
|
||||
|
||||
@dataclass
|
||||
class ContactPojo:
|
||||
@@ -35,6 +37,12 @@ class ContactPojo:
|
||||
|
||||
return dest
|
||||
|
||||
@staticmethod
|
||||
def get_contact_from_error_contact(errorContact: ContactInErrorPojo):
|
||||
return ContactPojo(phone_number=errorContact.phone, mail=errorContact.mail, ccid=errorContact.ccid,
|
||||
last_name=errorContact.last_name, first_name=errorContact.first_name,
|
||||
position=errorContact.position, passport_number=errorContact.passport)
|
||||
|
||||
@staticmethod
|
||||
def from_firestore_dict(source):
|
||||
ccid = source['ccid']
|
||||
|
||||
Reference in New Issue
Block a user