Coverage for functions \ flipdare \ generated \ model \ backend \ user_summary_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
32class UserSummaryKeys(StrEnum):
33 ID = "id"
34 CREATED_AT = "created_at"
35 UPDATED_AT = "updated_at"
36 UID = "uid"
37 REPORT_COUNT = "report_count"
38 TZ_STR = "tz_str"
39 VERSION = "version"
40 PROCESSED = "processed"
41 ERROR_COUNT = "error_count"
42 SUMMARY_SENT = "summary_sent"
45# !! IMPORTANT !!
46# !!
47# !! this should only be used in the database to query.
48# !!
49class UserSummaryInternalKeys(StrEnum):
50 CREATED_AT = "created_at"
51 UPDATED_AT = "updated_at"
52 VERSION = "VERSION"
53 PROCESSED = "INT_P"
54 ERROR_COUNT = "INT_E"
55 SUMMARY_SENT = "INT_SUM"
58class UserSummaryModel(AppBaseModel):
59 """Represents a user summary email."""
61 model_config = ConfigDict(populate_by_name=True, arbitrary_types_allowed=True)
63 id: str | None = Field(None, alias="id")
64 created_at: FirestoreField = Field(
65 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
66 )
67 updated_at: FirestoreField = Field(
68 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
69 )
70 uid: str
71 report_count: int = Field(default=1)
72 tz_str: str = Field(default="UTC")
73 # Version (base internal field)
74 version: int = Field(default=1, alias="VERSION")
75 # Processed (base internal field)
76 processed: bool = Field(default=False, alias="INT_P")
77 # Error Count (base internal field)
78 error_count: int = Field(default=0, alias="INT_E")
79 # Summary Sent (internal field)
80 summary_sent: bool = Field(default=False, alias="INT_SUM")
82 @classmethod
83 def validate_partial(cls, **data: Unpack[UserSummaryDict]) -> dict[str, Any]:
84 """
85 Uses Unpack to give you autocomplete and static warnings
86 if you pass an invalid key or type in your code.
88 Returns a dict with Firestore field names (aliases) for use with batch.update().
89 """
90 result: dict[str, Any] = {}
91 for k, v in data.items():
92 if k in cls.__pydantic_fields__:
93 field_info = cls.__pydantic_fields__[k]
94 validated_value = cast(
95 "Any",
96 TypeAdapter(field_info.annotation).validate_python(v),
97 )
98 # Use alias if defined, otherwise use field name
99 output_key = field_info.alias or k
100 result[output_key] = validated_value
101 return result
104USERSUMMARY_FIELD_NAMES: list[str] = list(UserSummaryModel.model_fields.keys())
107class UserSummaryDict(TypedDict, total=False):
108 id: str | None
109 created_at: Sentinel | datetime | str
110 updated_at: Sentinel | datetime | str
111 uid: str
112 report_count: int | None
113 tz_str: str | None
114 VERSION: int | None
115 INT_P: bool | None
116 INT_E: int | None
117 INT_SUM: bool | None