From a64cd12e9fba76796945e6e5aeeb5dbe0c73be63 Mon Sep 17 00:00:00 2001 From: Khiem Ton Date: Fri, 24 Mar 2023 15:38:21 +0700 Subject: [PATCH] fix: raid's location, datetime and constructor --- ispoof/objects/raid.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ispoof/objects/raid.py b/ispoof/objects/raid.py index d72e8d0..5e5d9e4 100644 --- a/ispoof/objects/raid.py +++ b/ispoof/objects/raid.py @@ -1,5 +1,6 @@ from datetime import datetime -from sqlalchemy import Column, String, Integer, Boolean, Time, PrimaryKeyConstraint +from ispoof.spoofer.location import Location +from sqlalchemy import Column, String, Integer, Boolean, DateTime, PrimaryKeyConstraint from sqlalchemy.orm import declarative_base Base = declarative_base() @@ -9,12 +10,21 @@ class Raid(Base): name = Column(String(30)) number = Column(Integer) - location = Column(String(50)) + location = Column(Location) level = Column(Integer) - start_time = Column(Time) - end_time = Column(Time) + start_time = Column(DateTime) + end_time = Column(DateTime) country = Column(String(2)) - PrimaryKeyConstraint(name, location, start_time, end_time, name="raid_pk") + PrimaryKeyConstraint(name, location, start_time, end_time, name="raid_pk", sqlite_on_conflict='IGNORE') + + def __init__(self, name, number, level, location, start_time, end_time, country): + self.name = name + self.number = number + self.level = level + self.location = location + self.start_time = start_time + self.end_time = end_time + self.country = country def is_dispawned(self): if datetime().now() > self.end_time: