Coverage for functions \ flipdare \ generated \ model \ backend \ app_stat_metric_model.py: 100%
0 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
1#!/usr/bin/env python
2#
3# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved.
4#
5# This file is part of Flipdare's proprietary software and contains
6# confidential and copyrighted material. Unauthorised copying,
7# modification, distribution, or use of this file is strictly
8# prohibited without prior written permission from Flipdare Pty Ltd.
9#
10# This software includes third-party components licensed under MIT,
11# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details.
12#
13# NOTE: THIS FILE IS AUTO GENERATED. DO NOT EDIT.
14#
15# Generated by codegen_models.py
16#
17# Modify 'codegen_models.py'
18# and re-run the script above to update.
19#
20# pragma: no cover
21from __future__ import annotations
22from datetime import datetime
23from google.cloud.firestore_v1.transforms import Sentinel
24from flipdare.core.firestore_field import FirestoreField
25from flipdare.util.time_util import FirestoreTime
26from typing import Any, TypedDict, cast, Unpack
27from enum import StrEnum
28from pydantic import Field, ConfigDict, TypeAdapter
29from flipdare.firestore.core.app_base_model import AppBaseModel
30from flipdare.generated.shared.backend.app_job_type import AppJobType
31from flipdare.generated.model.backend.metric.count_metric import CountMetric
32from flipdare.generated.model.backend.metric.outcome_metric import OutcomeMetric
35class AppStatMetricKeys(StrEnum):
36 ID = "id"
37 CREATED_AT = "created_at"
38 UPDATED_AT = "updated_at"
39 JOB_TYPE = "job_type"
40 METRIC = "metric"
43# !! IMPORTANT !!
44# !!
45# !! this should only be used in the database to query.
46# !!
47class AppStatMetricInternalKeys(StrEnum):
48 CREATED_AT = "created_at"
49 UPDATED_AT = "updated_at"
52class AppStatMetricModel(AppBaseModel):
53 """Daily metrics for app usage and performance."""
55 model_config = ConfigDict(populate_by_name=True, arbitrary_types_allowed=True)
57 id: str | None = Field(None, alias="id")
58 created_at: FirestoreField = Field(
59 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
60 )
61 updated_at: FirestoreField = Field(
62 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
63 )
64 job_type: AppJobType
65 metric: OutcomeMetric | CountMetric
67 @classmethod
68 def validate_partial(cls, **data: Unpack[AppStatMetricDict]) -> dict[str, Any]:
69 """
70 Uses Unpack to give you autocomplete and static warnings
71 if you pass an invalid key or type in your code.
73 Returns a dict with Firestore field names (aliases) for use with batch.update().
74 """
75 result: dict[str, Any] = {}
76 for k, v in data.items():
77 if k in cls.__pydantic_fields__:
78 field_info = cls.__pydantic_fields__[k]
79 validated_value = cast(
80 "Any",
81 TypeAdapter(field_info.annotation).validate_python(v),
82 )
83 # Use alias if defined, otherwise use field name
84 output_key = field_info.alias or k
85 result[output_key] = validated_value
86 return result
89APPSTATMETRIC_FIELD_NAMES: list[str] = list(AppStatMetricModel.model_fields.keys())
92class AppStatMetricDict(TypedDict, total=False):
93 id: str | None
94 created_at: Sentinel | datetime | str
95 updated_at: Sentinel | datetime | str
96 job_type: AppJobType
97 metric: OutcomeMetric | CountMetric