aboutsummaryrefslogtreecommitdiff
path: root/generalresearch/incite/schemas/mergers/foundations/enriched_session.py
blob: ee17bda281c1519160ee1cc0f7fa71a8ff0e43cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from datetime import timedelta

from pandera import Check, Column, DataFrameSchema

from generalresearch.incite.schemas import ARCHIVE_AFTER, ORDER_KEY, PARTITION_ON
from generalresearch.incite.schemas.thl_web import THLSessionSchema

thl_session_columns = THLSessionSchema.columns.copy()

EnrichedSessionSchema = DataFrameSchema(
    index=THLSessionSchema.index,
    columns=thl_session_columns
    | {
        # --- From thl_user MySQL-RR
        "product_id": Column(
            dtype=str,
            checks=Check.str_length(min_value=32, max_value=32),
            nullable=False,
        ),
        # -- nullable until it can be back-filled
        "team_id": Column(
            dtype=str,
            checks=Check.str_length(min_value=32, max_value=32),
            nullable=True,
        ),
        # --- Calculated from WallCollection ---
        "attempt_count": Column(dtype="Int64", nullable=False),
    },
    checks=[],
    coerce=True,
    metadata={
        ORDER_KEY: "started",
        ARCHIVE_AFTER: timedelta(minutes=90),
        PARTITION_ON: None,
    },
)