feat: add interval projection schema and models
Add time-series tracking tables for animal location, tag, and attribute history. Each interval represents a period when an animal had a specific state, with open intervals (end_utc=NULL) for current state. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
44
src/animaltrack/models/intervals.py
Normal file
44
src/animaltrack/models/intervals.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# ABOUTME: Pydantic models for time-series interval tracking.
|
||||
# ABOUTME: Tracks animal location, tag, and attribute history over time.
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class LocationInterval(BaseModel):
|
||||
"""Represents a period when an animal was at a specific location.
|
||||
|
||||
Open intervals (end_utc=None) indicate the animal is still at that location.
|
||||
"""
|
||||
|
||||
animal_id: str = Field(..., min_length=26, max_length=26)
|
||||
location_id: str = Field(..., min_length=26, max_length=26)
|
||||
start_utc: int
|
||||
end_utc: int | None = None
|
||||
|
||||
|
||||
class TagInterval(BaseModel):
|
||||
"""Represents a period when an animal had a specific tag.
|
||||
|
||||
Open intervals (end_utc=None) indicate the tag is still active.
|
||||
"""
|
||||
|
||||
animal_id: str = Field(..., min_length=26, max_length=26)
|
||||
tag: str
|
||||
start_utc: int
|
||||
end_utc: int | None = None
|
||||
|
||||
|
||||
class AttrInterval(BaseModel):
|
||||
"""Represents a period when an animal had a specific attribute value.
|
||||
|
||||
Tracks changes to sex, life_stage, repro_status, and status over time.
|
||||
Open intervals (end_utc=None) indicate the current attribute value.
|
||||
"""
|
||||
|
||||
animal_id: str = Field(..., min_length=26, max_length=26)
|
||||
attr: Literal["sex", "life_stage", "repro_status", "status"]
|
||||
value: str
|
||||
start_utc: int
|
||||
end_utc: int | None = None
|
||||
Reference in New Issue
Block a user