time_strategy.py 692 B

1234567891011121314151617181920212223
  1. from datetime import datetime
  2. from typing import Optional
  3. from dateutil.relativedelta import relativedelta
  4. from .current_time_strategy import PostgresCurrentTimePartitioningStrategy
  5. from .time_partition_size import PostgresTimePartitionSize
  6. class PostgresTimePartitioningStrategy(PostgresCurrentTimePartitioningStrategy):
  7. def __init__(
  8. self,
  9. start_datetime: datetime,
  10. size: PostgresTimePartitionSize,
  11. count: int,
  12. max_age: Optional[relativedelta] = None,
  13. ) -> None:
  14. super().__init__(size, count, max_age)
  15. self.start_datetime = start_datetime
  16. def get_start_datetime(self) -> datetime:
  17. return self.start_datetime