Coverage for postrfp / shared / serial / common.py: 100%
28 statements
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-03 01:35 +0000
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-03 01:35 +0000
1from datetime import datetime
2from typing import Optional
3from enum import StrEnum
5from pydantic import BaseModel, ConfigDict, Field
7# Import shared pagination schema to avoid duplication and circular imports
8# Re-export for backward compatibility
11class Id(BaseModel):
12 model_config = ConfigDict(from_attributes=True)
13 id: Optional[int] = None
16class StringId(BaseModel):
17 id: str
20class UID(BaseModel):
21 uid: str
24class TimestampedId(Id):
25 """
26 Provides id, date_created and date_updated fields
27 """
29 date_created: Optional[datetime] = None
30 date_updated: Optional[datetime] = None
33class ScoringModel(StrEnum):
34 """
35 Enum for score types
36 """
38 UNWEIGHTED = "Unweighted"
39 DIRECT = "Direct"
40 ABSOLUTE = "Absolute"
42 def __str__(self):
43 return self.value
46class Pagination(BaseModel):
47 """Schema for pagination information."""
49 current_page: int
50 page_size: int
51 total_count: int
52 total_pages: int
53 has_next: bool
54 current_page_count: int = Field(
55 0, description="Number of records in the current page"
56 )
59__all__ = ["Pagination", "Id", "StringId", "TimestampedId", "ScoringModel", "UID"]