main
Khiem Ton 2 years ago
parent 97a0c667e7
commit 1a1e54dfe3
Signed by: th4tkh13m
GPG Key ID: 4D9CF147DCADD05D

@ -1,8 +1,8 @@
from ispoof.core.location import Location
from ispoof.spoofer.location import Location
from sqlalchemy.orm import declarative_base
from sqlalchemy import Column, DateTime, PrimaryKeyConstraint
from sqlalchemy.orm import Session
from datetime import datetime, timedelta
from datetime import datetime
Base = declarative_base()

@ -1,11 +1,14 @@
from ispoof.objects.pokemon import Pokemon
from ispoof.core.location import Location
from ispoof.spoofer.location import Location
from thefuzz.fuzz import partial_ratio
from sqlalchemy.orm import Session
from sqlalchemy.engine import Engine
from typing import List
from sqlalchemy import desc
from datetime import datetime, timedelta
import logging
logger = logging.getLogger(__name__)
class PokemonList:
@ -50,9 +53,6 @@ class PokemonList:
with Session(self.engine) as session:
result = session.query(Pokemon).where(Pokemon.end_time > datetime.now() + self.timedelta)
session.commit()
print(len(result.all()))
print(type(result.all()))
print(result.all().sort(key=lambda pokemon: location.distance(pokemon.location), reverse=reverse))
return sorted(result.all(), key=lambda pokemon: location.distance(pokemon.location), reverse=reverse)
def search_by_name(self, query: str):
@ -62,6 +62,7 @@ class PokemonList:
return list(filter(lambda pokemon: partial_ratio(query.lower(), pokemon.name) >= 80, result.all()))
def insert_to_database(self, pokemons: List[Pokemon]):
logger.info("Add pokemons to database.")
with Session(self.engine) as session:
session.add_all(pokemons)
session.commit()

@ -1,5 +1,5 @@
from geopy.geocoders import Nominatim
from ispoof.core.location import Location
from ispoof.spoofer.location import Location
from ispoof.lists.playerhistory import PlayerHistory
from datetime import datetime, timedelta
from math import ceil

@ -1,6 +1,6 @@
from datetime import datetime
from sqlalchemy import Column, String, Integer, Boolean, DateTime, PrimaryKeyConstraint
from ispoof.core.location import Location
from ispoof.spoofer.location import Location
from sqlalchemy.orm import declarative_base
Base = declarative_base()

@ -3,6 +3,7 @@ from sqlalchemy import Column, String, Integer, Boolean, Time, PrimaryKeyConstra
from sqlalchemy.orm import declarative_base
Base = declarative_base()
class Raid(Base):
__tablename__ = "raid"

@ -2,7 +2,7 @@ from bs4 import BeautifulSoup
import requests
from ispoof.objects.pokemon import Pokemon
from ispoof.objects.raid import Raid
from ispoof.core.location import Location
from ispoof.spoofer.location import Location
from datetime import datetime

Loading…
Cancel
Save