diff options
| author | stuppie | 2026-11-04 12:11:03 -0600 |
|---|---|---|
| committer | stuppie | 2026-11-04 12:11:03 -0600 |
| commit | 671a7b1b02503cfa5c9aecd40c27a0c2729a285b (patch) | |
| tree | 6cb1bd7c33e3e1d243ee5ae74decc57faaa5742d /jb/models/bonus.py | |
| parent | e99ec6b7e38113a2237dc1ff402d8f4337c651d5 (diff) | |
| download | amt-jb-671a7b1b02503cfa5c9aecd40c27a0c2729a285b.tar.gz amt-jb-671a7b1b02503cfa5c9aecd40c27a0c2729a285b.zip | |
strip out AMT
Diffstat (limited to 'jb/models/bonus.py')
| -rw-r--r-- | jb/models/bonus.py | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/jb/models/bonus.py b/jb/models/bonus.py deleted file mode 100644 index c6da3c4..0000000 --- a/jb/models/bonus.py +++ /dev/null @@ -1,48 +0,0 @@ -from typing import Any - -from generalresearch.currency import USDCent -from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr -from pydantic import BaseModel, ConfigDict, Field, PositiveInt -from typing_extensions import Self - -from jb.models.custom_types import AMTBoto3ID - - -class Bonus(BaseModel): - """ - A Bonus is created (in our DB) ONLY associated with an APPROVED - thl-payout-event, AFTER the bonus has actually been sent to - the worker. - We have the payout_event uuid as the unique request token to make - sure it only gets sent once (param in the boto request). - """ - - model_config = ConfigDict( - extra="forbid", - validate_assignment=True, - ) - id: PositiveInt | None = Field(default=None) - assignment_id: PositiveInt | None = Field(default=None) - - amt_worker_id: str = Field(min_length=3, max_length=50) - amt_assignment_id: AMTBoto3ID = Field() - - amount: USDCent = Field() - reason: str = Field(min_length=5) - grant_time: AwareDatetimeISO = Field() - - # -- GRL Specific --- - payout_event_id: UUIDStr = Field() - # created: Optional[AwareDatetimeISO] = Field(default=None) - - def to_postgres(self): - d = self.model_dump(mode="json") - d["amount"] = self.amount.to_usd() - return d - - @classmethod - def from_postgres(cls, data: dict[str, Any]) -> Self: - data["amount"] = USDCent(round(data["amount"] * 100)) - fields = set(cls.model_fields.keys()) - data = {k: v for k, v in data.items() if k in fields} - return cls.model_validate(data) |
