Coverage for postrfp/shared/serial/common.py: 100%
26 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-22 21:34 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-22 21:34 +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 TimestampedId(Id):
21 """
22 Provides id, date_created and date_updated fields
23 """
25 date_created: Optional[datetime] = None
26 date_updated: Optional[datetime] = None
29class ScoringModel(StrEnum):
30 """
31 Enum for score types
32 """
34 UNWEIGHTED = "Unweighted"
35 DIRECT = "Direct"
36 ABSOLUTE = "Absolute"
38 def __str__(self):
39 return self.value
42class Pagination(BaseModel):
43 """Schema for pagination information."""
45 current_page: int
46 page_size: int
47 total_count: int
48 total_pages: int
49 has_next: bool
50 current_page_count: int = Field(
51 0, description="Number of records in the current page"
52 )
55__all__ = ["Pagination", "Id", "StringId", "TimestampedId", "ScoringModel"]