File: time_strategy.py

package info (click to toggle)
python-django-postgres-extra 2.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,096 kB
  • sloc: python: 9,057; makefile: 17; sh: 7; sql: 1
file content (23 lines) | stat: -rw-r--r-- 692 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from datetime import datetime
from typing import Optional

from dateutil.relativedelta import relativedelta

from .current_time_strategy import PostgresCurrentTimePartitioningStrategy
from .time_partition_size import PostgresTimePartitionSize


class PostgresTimePartitioningStrategy(PostgresCurrentTimePartitioningStrategy):
    def __init__(
        self,
        start_datetime: datetime,
        size: PostgresTimePartitionSize,
        count: int,
        max_age: Optional[relativedelta] = None,
    ) -> None:
        super().__init__(size, count, max_age)

        self.start_datetime = start_datetime

    def get_start_datetime(self) -> datetime:
        return self.start_datetime