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

1from datetime import datetime 

2from typing import Optional 

3from enum import StrEnum 

4 

5from pydantic import BaseModel, ConfigDict, Field 

6 

7# Import shared pagination schema to avoid duplication and circular imports 

8# Re-export for backward compatibility 

9 

10 

11class Id(BaseModel): 

12 model_config = ConfigDict(from_attributes=True) 

13 id: Optional[int] = None 

14 

15 

16class StringId(BaseModel): 

17 id: str 

18 

19 

20class UID(BaseModel): 

21 uid: str 

22 

23 

24class TimestampedId(Id): 

25 """ 

26 Provides id, date_created and date_updated fields 

27 """ 

28 

29 date_created: Optional[datetime] = None 

30 date_updated: Optional[datetime] = None 

31 

32 

33class ScoringModel(StrEnum): 

34 """ 

35 Enum for score types 

36 """ 

37 

38 UNWEIGHTED = "Unweighted" 

39 DIRECT = "Direct" 

40 ABSOLUTE = "Absolute" 

41 

42 def __str__(self): 

43 return self.value 

44 

45 

46class Pagination(BaseModel): 

47 """Schema for pagination information.""" 

48 

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 ) 

57 

58 

59__all__ = ["Pagination", "Id", "StringId", "TimestampedId", "ScoringModel", "UID"]