Skip to content

Database

db ¤

PB_VERSION module-attribute ¤

PB_VERSION = '0.21.1'

base_path module-attribute ¤

base_path = parent

ensure_pb_exists ¤

ensure_pb_exists()

_create_admin async ¤

_create_admin()

start async ¤

start(db_done: Event)

base ¤

BaseService ¤

BaseService(client: AsyncClient)
client instance-attribute ¤
client = client

client ¤

pb module-attribute ¤

pb = PocketBase()

PocketBase ¤

PocketBase(endpoint: str = cfg.db.PB_ENDPOINT)
client instance-attribute ¤
client = AsyncClient(
    base_url=endpoint, headers={"User-Agent": "am4-db"}
)
_user_api instance-attribute ¤
_user_api = UserAPI(client)
users property ¤
users
_login_admin async ¤
_login_admin(
    identity: str = cfg.db.PB_EMAIL,
    password: str = cfg.db.PB_PASSWORD,
)

models ¤

aircraft ¤

PyPaxConfigAlgorithm module-attribute ¤
PyPaxConfigAlgorithm = Literal[
    "AUTO", "FJY", "FYJ", "JFY", "JYF", "YFJ", "YJF"
]
PyCargoConfigAlgorithm module-attribute ¤
PyCargoConfigAlgorithm = Literal['AUTO', 'L', 'H']
PyConfigAlgorithmPax module-attribute ¤
PyConfigAlgorithmPax = Literal[
    "AUTO", "FJY", "FYJ", "JFY", "JYF", "YFJ", "YJF"
]
PyConfigAlgorithmCargo module-attribute ¤
PyConfigAlgorithmCargo = Literal['AUTO', 'L', 'H']
PyPaxConfig ¤

Bases: BaseModel

y instance-attribute ¤
y: int
j instance-attribute ¤
j: int
f instance-attribute ¤
f: int
algorithm instance-attribute ¤
PyCargoConfig ¤

Bases: BaseModel

l instance-attribute ¤
l: int
h instance-attribute ¤
h: int
algorithm instance-attribute ¤
PyAircraft ¤

Bases: BaseModel

id instance-attribute ¤
id: int
shortname instance-attribute ¤
shortname: str
manufacturer instance-attribute ¤
manufacturer: str
name instance-attribute ¤
name: str
type instance-attribute ¤
type: Literal['PAX', 'CARGO', 'VIP']
priority instance-attribute ¤
priority: int
eid instance-attribute ¤
eid: int
ename instance-attribute ¤
ename: str
speed instance-attribute ¤
speed: float
fuel instance-attribute ¤
fuel: float
co2 instance-attribute ¤
co2: float
cost instance-attribute ¤
cost: int
capacity instance-attribute ¤
capacity: int
rwy instance-attribute ¤
rwy: int
check_cost instance-attribute ¤
check_cost: int
range instance-attribute ¤
range: int
ceil instance-attribute ¤
ceil: int
maint instance-attribute ¤
maint: int
pilots instance-attribute ¤
pilots: int
crew instance-attribute ¤
crew: int
engineers instance-attribute ¤
engineers: int
technicians instance-attribute ¤
technicians: int
img instance-attribute ¤
img: str
wingspan instance-attribute ¤
wingspan: int
length instance-attribute ¤
length: int
speed_mod instance-attribute ¤
speed_mod: bool
fuel_mod instance-attribute ¤
fuel_mod: bool
co2_mod instance-attribute ¤
co2_mod: bool
fourx_mod instance-attribute ¤
fourx_mod: bool
PyAircraftSuggestion ¤

Bases: BaseModel

ac instance-attribute ¤
score instance-attribute ¤
score: float

airport ¤

PyAirport ¤

Bases: BaseModel

id instance-attribute ¤
id: int
name instance-attribute ¤
name: str
fullname instance-attribute ¤
fullname: str
country instance-attribute ¤
country: str
continent instance-attribute ¤
continent: str
iata instance-attribute ¤
iata: str
icao instance-attribute ¤
icao: str
lat instance-attribute ¤
lat: float
lng instance-attribute ¤
lng: float
rwy instance-attribute ¤
rwy: int
market instance-attribute ¤
market: int
hub_cost instance-attribute ¤
hub_cost: int
rwy_codes instance-attribute ¤
rwy_codes: str
PyAirportSuggestion ¤

Bases: BaseModel

ap instance-attribute ¤
score instance-attribute ¤
score: float

demand ¤

PyPaxDemand ¤

Bases: BaseModel

y instance-attribute ¤
y: int
j instance-attribute ¤
j: int
f instance-attribute ¤
f: int
PyCargoDemand ¤

Bases: BaseModel

l instance-attribute ¤
l: int
h instance-attribute ¤
h: int

game ¤

StrToUpper module-attribute ¤
StrToUpper = BeforeValidator(
    func=lambda x: strip() if isinstance(x, str) else x
)
StrPctToFloat module-attribute ¤
StrPctToFloat = BeforeValidator(
    func=lambda x: (
        float(replace("%", "e-2"))
        if isinstance(x, str) and endswith("%")
        else x
    )
)
PyUserWhitelistedKeys module-attribute ¤
PyUserWhitelistedKeys = Literal[
    "game_id",
    "game_name",
    "game_mode",
    "wear_training",
    "repair_training",
    "l_training",
    "h_training",
    "fuel_training",
    "co2_training",
    "fuel_price",
    "co2_price",
    "accumulated_count",
    "load",
    "income_loss_tol",
    "fourx",
]
PyUser ¤

Bases: BaseModel

id instance-attribute ¤
id: str
username instance-attribute ¤
username: str
game_id instance-attribute ¤
game_id: int
game_name instance-attribute ¤
game_name: str
game_mode instance-attribute ¤
game_mode: Literal['EASY', 'REALISM']
discord_id instance-attribute ¤
discord_id: int
wear_training instance-attribute ¤
wear_training: int
repair_training instance-attribute ¤
repair_training: int
l_training instance-attribute ¤
l_training: int
h_training instance-attribute ¤
h_training: int
fuel_training instance-attribute ¤
fuel_training: int
co2_training instance-attribute ¤
co2_training: int
fuel_price instance-attribute ¤
fuel_price: int
co2_price instance-attribute ¤
co2_price: int
accumulated_count instance-attribute ¤
accumulated_count: int
load instance-attribute ¤
load: float
income_loss_tol instance-attribute ¤
income_loss_tol: float
fourx instance-attribute ¤
fourx: bool
role instance-attribute ¤
role: Literal[
    "BANNED",
    "USER",
    "TRUSTED_USER",
    "HIGHLY_TRUSTED_USER",
    "TOP_ALLIANCE_MEMBER",
    "TOP_ALLIANCE_ADMIN",
    "HELPER",
    "MODERATOR",
    "ADMIN",
    "SUPERUSER",
]
valid instance-attribute ¤
valid: bool

route ¤

PyACROptionsConfigAlgorithm module-attribute ¤
PyACROptionsConfigAlgorithm = Literal[
    PyConfigAlgorithmPax, PyConfigAlgorithmCargo
]
PyACROptionsMaxDistance module-attribute ¤
PyACROptionsMaxDistance = float
PyACROptionsMaxFlightTime module-attribute ¤
PyACROptionsMaxFlightTime = float
PyACROptionsTPDMode module-attribute ¤
PyACROptionsTPDMode = Literal[
    "AUTO", "STRICT_ALLOW_MULTIPLE_AC", "STRICT"
]
PyACROptionsTripsPerDayPerAC module-attribute ¤
PyACROptionsTripsPerDayPerAC = int
PyACROptionsSortBy module-attribute ¤
PyACROptionsSortBy = Literal['PER_TRIP', 'PER_AC_PER_DAY']
PyRoute ¤

Bases: BaseModel

pax_demand instance-attribute ¤
pax_demand: PyPaxDemand
direct_distance instance-attribute ¤
direct_distance: float
PyACRouteStopover ¤

Bases: BaseModel

airport instance-attribute ¤
airport: PyAirport
full_distance instance-attribute ¤
full_distance: float
exists class-attribute instance-attribute ¤
exists: Literal[True] = Field(True, frozen=True)
PyACRouteStopoverNonExistent ¤

Bases: BaseModel

exists class-attribute instance-attribute ¤
exists: Literal[False] = Field(False, frozen=True)
PyACRoute ¤

Bases: BaseModel

route instance-attribute ¤
route: PyRoute
config class-attribute instance-attribute ¤
trips_per_day_per_ac class-attribute instance-attribute ¤
trips_per_day_per_ac: Optional[int] = None
ticket class-attribute instance-attribute ¤
max_income class-attribute instance-attribute ¤
max_income: Optional[float] = None
income class-attribute instance-attribute ¤
income: Optional[float] = None
fuel class-attribute instance-attribute ¤
fuel: Optional[float] = None
co2 class-attribute instance-attribute ¤
co2: Optional[float] = None
acheck_cost class-attribute instance-attribute ¤
acheck_cost: Optional[float] = None
repair_cost class-attribute instance-attribute ¤
repair_cost: Optional[float] = None
flight_time class-attribute instance-attribute ¤
flight_time: Optional[float] = None
num_ac class-attribute instance-attribute ¤
num_ac: Optional[int] = None
needs_stopover class-attribute instance-attribute ¤
needs_stopover: Optional[bool] = None
profit class-attribute instance-attribute ¤
profit: Optional[float] = None
contribution class-attribute instance-attribute ¤
contribution: Optional[float] = None
ci class-attribute instance-attribute ¤
ci: Optional[int] = None
stopover class-attribute instance-attribute ¤
warnings instance-attribute ¤
warnings: list[
    Literal[
        "ERR_DISTANCE_ABOVE_SPECIFIED",
        "ERR_DISTANCE_TOO_LONG",
        "ERR_DISTANCE_TOO_SHORT",
        "REDUCED_CONTRIBUTION",
        "ERR_NO_STOPOVER",
        "ERR_FLIGHT_TIME_ABOVE_SPECIFIED",
        "ERR_INSUFFICIENT_DEMAND",
        "ERR_TRIPS_PER_DAY_TOO_HIGH",
    ]
]
valid instance-attribute ¤
valid: Optional[bool]
max_tpd instance-attribute ¤
max_tpd: Optional[int]

ticket ¤

PyPaxTicket ¤

Bases: BaseModel

y instance-attribute ¤
y: int
j instance-attribute ¤
j: int
f instance-attribute ¤
f: int
PyCargoTicket ¤

Bases: BaseModel

l instance-attribute ¤
l: float
h instance-attribute ¤
h: float
PyVIPTicket ¤

Bases: BaseModel

y instance-attribute ¤
y: int
j instance-attribute ¤
j: int
f instance-attribute ¤
f: int

util ¤

assert_equal_property_names ¤
assert_equal_property_names(
    pybind_class: type, pydantic_class: type
)

user ¤

DBMessageUser module-attribute ¤

DBMessageUser = Literal['found', 'created']

UserExtra ¤

Bases: BaseModel

collectionId instance-attribute ¤
collectionId: str
collectionName instance-attribute ¤
collectionName: str
created instance-attribute ¤
created: datetime
email class-attribute instance-attribute ¤
email: str | None = None
emailVisibility instance-attribute ¤
emailVisibility: bool
metadata instance-attribute ¤
metadata: dict | None
updated instance-attribute ¤
updated: datetime
verified instance-attribute ¤
verified: bool
model_config class-attribute instance-attribute ¤
model_config = ConfigDict(extra='ignore')

UserAPI ¤

UserAPI(client: AsyncClient)

Bases: BaseService

client instance-attribute ¤
client = client
_list async ¤
_list()
get_from_discord async ¤
get_from_discord(
    username: str,
    game_name: str,
    game_mode: Literal["EASY", "REALISM"],
    discord_id: int,
) -> tuple[User, UserExtra, DBMessageUser]
update_setting async ¤
update_setting(userid: str, key: str, value: str) -> str