Skip to content

Commit 2dca75a

Browse files
committed
Fixed plotting (at least tests), still missing frontend
1 parent f390d9d commit 2dca75a

8 files changed

Lines changed: 20 additions & 44 deletions

File tree

src/backend_api/app/core/schemas/plot/input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class WantedModifier(_pydantic.BaseModel):
3939

4040

4141
class BasePlotQuery(_pydantic.BaseModel):
42-
league: list[str] | str
42+
leagueId: list[int] | int
4343
itemSpecifications: ItemSpecs | None = None
4444
baseSpecifications: BaseSpecs | None = None
4545
end: int | None = None

src/backend_api/app/core/schemas/plot/output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Datum(_pydantic.BaseModel):
1111

1212

1313
class TimeseriesData(_pydantic.BaseModel):
14-
name: str
14+
name: int
1515
data: list[Datum]
1616
confidenceRating: Literal["low", "medium", "high"]
1717

src/backend_api/app/plotting/plotter.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def _init_stmt(
9797
select_args: list[InstrumentedAttribute[Any] | Label[Any]] = [
9898
item_model.itemId,
9999
item_model.createdHoursSinceLaunch,
100-
item_model.league,
100+
item_model.leagueId,
101101
item_model.itemBaseTypeId,
102102
item_model.currencyId,
103103
item_model.currencyAmount,
@@ -114,12 +114,12 @@ def _init_stmt(
114114
model_Currency, item_model.currencyId == model_Currency.currencyId
115115
)
116116

117-
if isinstance(query.league, list):
117+
if isinstance(query.leagueId, list):
118118
stmt = stmt.where(
119-
or_(*[item_model.league == league for league in query.league])
119+
or_(*[item_model.leagueId == league for league in query.leagueId])
120120
)
121121
else:
122-
stmt = stmt.where(model_Item.league == query.league)
122+
stmt = stmt.where(model_Item.leagueId == query.leagueId)
123123

124124
if start is not None:
125125
stmt = stmt.where(item_model.createdHoursSinceLaunch >= start)
@@ -223,8 +223,8 @@ def _create_plot_data(self, df: pd.DataFrame) -> PlotData:
223223
0, "divine"
224224
) # TODO: set enum
225225
data = []
226-
for league in df["league"].unique():
227-
league_df: pd.DataFrame = df.loc[df["league"] == league]
226+
for league in df["leagueId"].unique():
227+
league_df: pd.DataFrame = df.loc[df["leagueId"] == league]
228228
league_data = league_df[
229229
[
230230
"hoursSinceLaunch",
@@ -443,7 +443,7 @@ def _create_plot_statement(self, query: IdentifiedPlotQuery) -> Select:
443443
base_query.c.tradeName.label("mostCommonTradeName"),
444444
func.count(base_query.c.tradeName).label("nameCount"),
445445
)
446-
.group_by(base_query.c.league, base_query.c.tradeName)
446+
.group_by(base_query.c.leagueId, base_query.c.tradeName)
447447
.order_by(desc("nameCount")) # Can use literal_column in complex cases
448448
.limit(1)
449449
.cte("mostCommon")
@@ -486,7 +486,7 @@ def _create_plot_statement(self, query: IdentifiedPlotQuery) -> Select:
486486
prices = (
487487
select(
488488
base_query.c.createdHoursSinceLaunch,
489-
base_query.c.league,
489+
base_query.c.leagueId,
490490
(base_query.c.currencyAmount * base_query.c.valueInChaos).label(
491491
"valueInChaos"
492492
),
@@ -519,7 +519,7 @@ def _create_plot_statement(self, query: IdentifiedPlotQuery) -> Select:
519519
filtered_prices = (
520520
select(
521521
ranked_prices.c.createdHoursSinceLaunch,
522-
ranked_prices.c.league,
522+
ranked_prices.c.leagueId,
523523
ranked_prices.c.valueInChaos,
524524
ranked_prices.c.valueInMostCommonCurrencyUsed,
525525
ranked_prices.c.mostCommonCurrencyUsed,
@@ -537,7 +537,7 @@ def _create_plot_statement(self, query: IdentifiedPlotQuery) -> Select:
537537
final_query = (
538538
select(
539539
filtered_prices.c.createdHoursSinceLaunch.label("hoursSinceLaunch"),
540-
filtered_prices.c.league,
540+
filtered_prices.c.leagueId,
541541
func.avg(filtered_prices.c.valueInChaos).label("valueInChaos"),
542542
func.avg(filtered_prices.c.valueInMostCommonCurrencyUsed).label(
543543
"valueInMostCommonCurrencyUsed"
@@ -548,7 +548,7 @@ def _create_plot_statement(self, query: IdentifiedPlotQuery) -> Select:
548548
func.min(filtered_prices.c.confidence).label("confidence"),
549549
)
550550
.group_by(
551-
filtered_prices.c.createdHoursSinceLaunch, filtered_prices.c.league
551+
filtered_prices.c.createdHoursSinceLaunch, filtered_prices.c.leagueId
552552
)
553553
.order_by(filtered_prices.c.createdHoursSinceLaunch)
554554
)

src/backend_api/app/tests/utils/model_utils/item.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async def generate_random_item(
9999
) -> tuple[
100100
dict,
101101
Item,
102-
list[dict | ItemBaseType | Currency] | None,
102+
list[dict | ItemBaseType | Currency | League] | None,
103103
]:
104104
"""Generate a random item.
105105

src/backend_api/app/tests/utils/model_utils/item_modifier.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Item,
77
ItemBaseType,
88
ItemModifier,
9+
League,
910
Modifier,
1011
)
1112
from app.core.schemas.item_modifier import ItemModifierCreate
@@ -20,7 +21,7 @@ async def create_random_item_modifier_dict(
2021
dict
2122
| tuple[
2223
dict,
23-
list[dict | ItemBaseType | Currency | Item | Modifier] | None,
24+
list[dict | ItemBaseType | Currency | League | Item | Modifier] | None,
2425
]
2526
):
2627
"""Create a random item modifier dictionary.
@@ -66,7 +67,7 @@ async def generate_random_item_modifier(
6667
) -> tuple[
6768
dict,
6869
ItemModifier,
69-
list[dict | ItemBaseType | Currency | Item | Modifier] | None,
70+
list[dict | ItemBaseType | Currency | League | Item | Modifier] | None,
7071
]:
7172
"""Generate a random item modifier.
7273

src/backend_api/app/tests/utils/model_utils/plot.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from sqlalchemy.orm import Session
44

55
from app.core.models.models import (
6-
Item as model_Item,
6+
League as model_League,
77
)
88
from app.core.models.models import (
99
Modifier as model_Modifier,
@@ -24,35 +24,17 @@ async def create_minimal_random_plot_query_dict(db: Session) -> dict[str, Any]:
2424
db, retrieve_dependencies=True
2525
)
2626

27-
item_dep: model_Item = item_modifier_deps[-3]
27+
league_dep: model_League = item_modifier_deps[-3]
2828
modifier_dep: model_Modifier = item_modifier_deps[-1]
2929

30-
item_specs = {
31-
"name": None,
32-
"identified": None,
33-
"minIlvl": None,
34-
"maxIlvl": None,
35-
"rarity": None,
36-
"corrupted": None,
37-
"delve": None,
38-
"fractured": None,
39-
"synthesised": None,
40-
"replica": None,
41-
"influences": None,
42-
"searing": None,
43-
"tangled": None,
44-
"foilVariation": None,
45-
}
46-
4730
wanted_modifiers = [
4831
{
4932
"modifierId": modifier_dep.modifierId,
5033
}
5134
]
5235

5336
plot_query = {
54-
"league": item_dep.league,
55-
"itemSpecifications": item_specs,
37+
"leagueId": league_dep.leagueId,
5638
"wantedModifiers": wanted_modifiers,
5739
}
5840

src/backend_data_retrieval/data_retrieval_app/external_data_retrieval/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def CURRENT_HARDCORE_LEAGUE(self) -> str:
4141
MINI_BATCH_SIZE: int = 30
4242
N_CHECKPOINTS_PER_TRANSFORMATION: int = 10
4343

44-
TIME_BETWEEN_RESTART: int = 3600
4544
MAX_TIME_PER_MINI_BATCH: int = 3 * 60
4645

4746
LEAGUE_LAUNCH_TIME: str

src/backend_data_retrieval/data_retrieval_app/external_data_retrieval/data_retrieval/poe_api_handler.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ def __init__(
8484

8585
self._program_too_slow = False
8686
self._program_finished = False
87-
self.time_of_launch = time.perf_counter()
88-
self.run_program_for_n_seconds = settings.TIME_BETWEEN_RESTART
8987
logger.info("PoEAPIHandler successfully initialized.")
9088

9189
self.n_checkpoints_per_transfromation = (
@@ -531,7 +529,3 @@ def dump_stream(self, track_progress: bool = True) -> Iterator[pd.DataFrame]:
531529
yield df.reset_index()
532530
del df
533531
logger.info("Finished transformation phase")
534-
current_time = time.perf_counter()
535-
time_since_launch = current_time - self.time_of_launch
536-
if time_since_launch > self.run_program_for_n_seconds:
537-
raise ProgramFinished

0 commit comments

Comments
 (0)