Coverage for functions \ flipdare \ generated \ model \ issue \ issue_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.model.issue.issue_type import IssueType
31from flipdare.generated.shared.model.issue.issue_progress import IssueProgress
32from flipdare.generated.shared.model.model_obj_type import ModelObjType
33from flipdare.generated.model.issue.resolution_comment_model import (
34 ResolutionCommentModel,
35 ResolutionCommentDict,
36)
39class IssueKeys(StrEnum):
40 ID = "id"
41 CREATED_AT = "created_at"
42 UPDATED_AT = "updated_at"
43 SLUG_CODE = "slug_code"
44 ISSUE_TYPE = "issue_type"
45 PROGRESS = "progress"
46 FROM_UID = "from_uid"
47 DESCRIPTION = "description"
48 TO_UID = "to_uid"
49 OBJ_ID = "obj_id"
50 OBJ_TYPE = "obj_type"
51 RESOLUTION = "resolution"
52 COMMENT_COUNT = "comment_count"
53 VERSION = "version"
54 PROCESSED = "processed"
55 ERROR_COUNT = "error_count"
58# !! IMPORTANT !!
59# !!
60# !! this should only be used in the database to query.
61# !!
62class IssueInternalKeys(StrEnum):
63 CREATED_AT = "created_at"
64 UPDATED_AT = "updated_at"
65 VERSION = "VERSION"
66 PROCESSED = "INT_P"
67 ERROR_COUNT = "INT_E"
70class IssueModel(AppBaseModel):
71 """Represents a user-generated issue or report in the system, which can be associated with various objects such as dares, comments, or users."""
73 model_config = ConfigDict(populate_by_name=True, arbitrary_types_allowed=True)
75 id: str | None = Field(None, alias="id")
76 created_at: FirestoreField = Field(
77 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
78 )
79 updated_at: FirestoreField = Field(
80 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
81 )
82 slug_code: str
83 issue_type: IssueType
84 progress: IssueProgress
85 from_uid: str
86 description: str
87 to_uid: str | None = None
88 obj_id: str | None = None
89 obj_type: ModelObjType | None = None
90 resolution: ResolutionCommentModel | None = None
91 comment_count: int = Field(default=0)
92 # Version (base internal field)
93 version: int = Field(default=1, alias="VERSION")
94 # Processed (base internal field)
95 processed: bool = Field(default=False, alias="INT_P")
96 # Error Count (base internal field)
97 error_count: int = Field(default=0, alias="INT_E")
99 @classmethod
100 def validate_partial(cls, **data: Unpack[IssueDict]) -> dict[str, Any]:
101 """
102 Uses Unpack to give you autocomplete and static warnings
103 if you pass an invalid key or type in your code.
105 Returns a dict with Firestore field names (aliases) for use with batch.update().
106 """
107 result: dict[str, Any] = {}
108 for k, v in data.items():
109 if k in cls.__pydantic_fields__:
110 field_info = cls.__pydantic_fields__[k]
111 validated_value = cast(
112 "Any",
113 TypeAdapter(field_info.annotation).validate_python(v),
114 )
115 # Use alias if defined, otherwise use field name
116 output_key = field_info.alias or k
117 result[output_key] = validated_value
118 return result
121ISSUE_FIELD_NAMES: list[str] = list(IssueModel.model_fields.keys())
124class IssueDict(TypedDict, total=False):
125 id: str | None
126 created_at: Sentinel | datetime | str
127 updated_at: Sentinel | datetime | str
128 slug_code: str
129 issue_type: IssueType
130 progress: IssueProgress
131 from_uid: str
132 description: str
133 to_uid: str | None
134 obj_id: str | None
135 obj_type: ModelObjType | None
136 resolution: ResolutionCommentDict | None
137 comment_count: int | None
138 VERSION: int | None
139 INT_P: bool | None
140 INT_E: int | None