aboutsummaryrefslogtreecommitdiff
path: root/generalresearch/models/thl
diff options
context:
space:
mode:
Diffstat (limited to 'generalresearch/models/thl')
-rw-r--r--generalresearch/models/thl/contest/definitions.py16
-rw-r--r--generalresearch/models/thl/definitions.py22
-rw-r--r--generalresearch/models/thl/demographics.py4
-rw-r--r--generalresearch/models/thl/leaderboard.py8
-rw-r--r--generalresearch/models/thl/ledger.py14
-rw-r--r--generalresearch/models/thl/offerwall/__init__.py6
-rw-r--r--generalresearch/models/thl/product.py6
-rw-r--r--generalresearch/models/thl/profiling/upk_property.py6
-rw-r--r--generalresearch/models/thl/profiling/upk_question.py8
-rw-r--r--generalresearch/models/thl/supplier_tag.py4
-rw-r--r--generalresearch/models/thl/survey/__init__.py1
-rw-r--r--generalresearch/models/thl/user_quality_event.py6
-rw-r--r--generalresearch/models/thl/user_streak.py10
-rw-r--r--generalresearch/models/thl/userhealth.py4
-rw-r--r--generalresearch/models/thl/wallet/__init__.py6
-rw-r--r--generalresearch/models/thl/wallet/cashout_method.py19
16 files changed, 68 insertions, 72 deletions
diff --git a/generalresearch/models/thl/contest/definitions.py b/generalresearch/models/thl/contest/definitions.py
index 1a71408..cc0ee05 100644
--- a/generalresearch/models/thl/contest/definitions.py
+++ b/generalresearch/models/thl/contest/definitions.py
@@ -1,17 +1,17 @@
from __future__ import annotations
-from enum import Enum
+from enum import StrEnum
from generalresearch.utils.enum import ReprEnumMeta
-class ContestStatus(str, Enum):
+class ContestStatus(StrEnum):
ACTIVE = "active"
COMPLETED = "completed"
CANCELLED = "cancelled"
-class ContestType(str, Enum, metaclass=ReprEnumMeta):
+class ContestType(StrEnum, metaclass=ReprEnumMeta):
"""There are 3 contest types. They have a common base, with some unique
configurations and behaviors for each.
"""
@@ -26,7 +26,7 @@ class ContestType(str, Enum, metaclass=ReprEnumMeta):
MILESTONE = "milestone"
-class ContestEndReason(str, Enum):
+class ContestEndReason(StrEnum):
"""
Defines why a contest ended
"""
@@ -44,7 +44,7 @@ class ContestEndReason(str, Enum):
MAX_WINNERS = "max_winners"
-class ContestPrizeKind(str, Enum, metaclass=ReprEnumMeta):
+class ContestPrizeKind(StrEnum, metaclass=ReprEnumMeta):
# A physical prize (e.g. a iPhone, cash in the mail, dinner with Max)
PHYSICAL = "physical"
@@ -56,7 +56,7 @@ class ContestPrizeKind(str, Enum, metaclass=ReprEnumMeta):
CASH = "cash"
-class ContestEntryTrigger(str, Enum):
+class ContestEntryTrigger(StrEnum):
"""
Defines what action/event triggers a (possible) entry into the contest (automatically).
This only is valid on milestone contests
@@ -67,7 +67,7 @@ class ContestEntryTrigger(str, Enum):
REFERRAL = "referral"
-class ContestEntryType(str, Enum, metaclass=ReprEnumMeta):
+class ContestEntryType(StrEnum, metaclass=ReprEnumMeta):
"""
All entries into a contest must be of the same type, and match
the entry_type of the Contest itself.
@@ -83,7 +83,7 @@ class ContestEntryType(str, Enum, metaclass=ReprEnumMeta):
CASH = "cash"
-class LeaderboardTieBreakStrategy(str, Enum):
+class LeaderboardTieBreakStrategy(StrEnum):
"""
Strategies for resolving ties in leaderboard-based contests.
"""
diff --git a/generalresearch/models/thl/definitions.py b/generalresearch/models/thl/definitions.py
index 22ca4b9..0217a80 100644
--- a/generalresearch/models/thl/definitions.py
+++ b/generalresearch/models/thl/definitions.py
@@ -1,10 +1,10 @@
import copy
-from enum import Enum
+from enum import IntEnum, StrEnum
from generalresearch.utils.enum import ReprEnumMeta
-class ReservedQueryParameters(str, Enum, metaclass=ReprEnumMeta):
+class ReservedQueryParameters(StrEnum, metaclass=ReprEnumMeta):
PRODUCT_ID = "product_id"
PRODUCT_USER_ID = "bp_user_id"
BPUID = "bpuid"
@@ -48,7 +48,7 @@ class ReservedQueryParameters(str, Enum, metaclass=ReprEnumMeta):
N_BINS = "n_bins"
-class THLPaths(str, Enum, metaclass=ReprEnumMeta):
+class THLPaths(StrEnum, metaclass=ReprEnumMeta):
# Endpoints on thl-fsb
TASK_ADJUSTMENT = "f4484dbdf144451ab60cda256ce14266"
@@ -65,7 +65,7 @@ class THLPaths(str, Enum, metaclass=ReprEnumMeta):
GET_GRLIQ_JS_ATTR = "4a2954b34cc24f93be3e8b218e323b88"
-class Status(str, Enum, metaclass=ReprEnumMeta):
+class Status(StrEnum, metaclass=ReprEnumMeta):
"""
The outcome of a session or wall event. If the session is still in
progress, the status will be NULL.
@@ -85,7 +85,7 @@ class Status(str, Enum, metaclass=ReprEnumMeta):
TIMEOUT = "t"
-class WallAdjustedStatus(str, Enum, metaclass=ReprEnumMeta):
+class WallAdjustedStatus(StrEnum, metaclass=ReprEnumMeta):
# Task was reconciled to complete
ADJUSTED_TO_COMPLETE = "ac"
# Task was reconciled to incomplete
@@ -100,7 +100,7 @@ class WallAdjustedStatus(str, Enum, metaclass=ReprEnumMeta):
CONFIRMED_COMPLETE = "cc"
-class SessionAdjustedStatus(str, Enum, metaclass=ReprEnumMeta):
+class SessionAdjustedStatus(StrEnum, metaclass=ReprEnumMeta):
"""An adjusted_status is set if a session is adjusted by the marketplace
after the original return. A session can be adjusted multiple times.
This is the most recent status. If a session was originally a complete,
@@ -117,7 +117,7 @@ class SessionAdjustedStatus(str, Enum, metaclass=ReprEnumMeta):
PAYOUT_ADJUSTMENT = "pa"
-class StatusCode1(int, Enum, metaclass=ReprEnumMeta):
+class StatusCode1(IntEnum, metaclass=ReprEnumMeta):
"""
__High level status code for outcome of the session.__
This should only be NULL if the Status is ABANDON or TIMEOUT
@@ -177,7 +177,7 @@ class StatusCode1(int, Enum, metaclass=ReprEnumMeta):
SESSION_CONTINUE_QUALITY_FAIL = 19
-class SessionStatusCode2(int, Enum, metaclass=ReprEnumMeta):
+class SessionStatusCode2(IntEnum, metaclass=ReprEnumMeta):
"""
__Status Detail__
This should be set if the Session.status_code_1 is SESSION_XXX_FAIL
@@ -217,7 +217,7 @@ class SessionStatusCode2(int, Enum, metaclass=ReprEnumMeta):
GRLIQ_MISSING = 13
-class WallStatusCode2(int, Enum, metaclass=ReprEnumMeta):
+class WallStatusCode2(IntEnum, metaclass=ReprEnumMeta):
"""
This should be set if the Wall.status_code_1 is MARKETPLACE_FAIL
"""
@@ -289,7 +289,7 @@ WALL_ALLOWED_STATUS_CODE_1_2 = {
}
-class ReportValue(int, Enum, metaclass=ReprEnumMeta):
+class ReportValue(IntEnum, metaclass=ReprEnumMeta):
"""
The reason a user reported a task.
"""
@@ -316,7 +316,7 @@ class ReportValue(int, Enum, metaclass=ReprEnumMeta):
DIDNT_LIKE = 7
-class PayoutStatus(str, Enum, metaclass=ReprEnumMeta):
+class PayoutStatus(StrEnum, metaclass=ReprEnumMeta):
"""The max size of the db field that holds this value is 20, so please
don't add new values longer than that!
"""
diff --git a/generalresearch/models/thl/demographics.py b/generalresearch/models/thl/demographics.py
index 4d4c8c2..b6a8be1 100644
--- a/generalresearch/models/thl/demographics.py
+++ b/generalresearch/models/thl/demographics.py
@@ -3,7 +3,7 @@ from __future__ import annotations
import copy
from collections import Counter, defaultdict
from dataclasses import dataclass
-from enum import Enum
+from enum import Enum, StrEnum
from typing import TYPE_CHECKING, Any, Literal
import numpy as np
@@ -35,7 +35,7 @@ class DemographicTarget:
}
-class Gender(str, Enum):
+class Gender(StrEnum):
"""
The respondent's gender
"""
diff --git a/generalresearch/models/thl/leaderboard.py b/generalresearch/models/thl/leaderboard.py
index dce3280..4d116a5 100644
--- a/generalresearch/models/thl/leaderboard.py
+++ b/generalresearch/models/thl/leaderboard.py
@@ -2,8 +2,8 @@ from __future__ import annotations
import logging
import math
-from datetime import UTC, datetime, timedelta, timezone
-from enum import Enum
+from datetime import UTC, datetime, timedelta
+from enum import StrEnum
from typing import Literal
from uuid import UUID, uuid3
from zoneinfo import ZoneInfo
@@ -27,7 +27,7 @@ from generalresearch.utils.enum import ReprEnumMeta
logger = logging.getLogger()
-class LeaderboardCode(str, Enum, metaclass=ReprEnumMeta):
+class LeaderboardCode(StrEnum, metaclass=ReprEnumMeta):
"""
The type of leaderboard. What the "values" represent.
"""
@@ -40,7 +40,7 @@ class LeaderboardCode(str, Enum, metaclass=ReprEnumMeta):
SUM_PAYOUTS = "sum_user_payout"
-class LeaderboardFrequency(str, Enum, metaclass=ReprEnumMeta):
+class LeaderboardFrequency(StrEnum, metaclass=ReprEnumMeta):
"""
The time period range for the leaderboard.
"""
diff --git a/generalresearch/models/thl/ledger.py b/generalresearch/models/thl/ledger.py
index dd37d98..19dde20 100644
--- a/generalresearch/models/thl/ledger.py
+++ b/generalresearch/models/thl/ledger.py
@@ -1,8 +1,8 @@
from __future__ import annotations
-from datetime import UTC, datetime, timezone
-from enum import Enum
-from typing import Annotated, Any, Literal, Self, Union
+from datetime import UTC, datetime
+from enum import StrEnum
+from typing import Annotated, Any, Literal, Self
from uuid import uuid4
from pydantic import (
@@ -50,13 +50,13 @@ class Direction(int, Enum, metaclass=ReprEnumMeta):
DEBIT = 1
-class OrderBy(str, Enum, metaclass=ReprEnumMeta):
+class OrderBy(StrEnum, metaclass=ReprEnumMeta):
ASC = "ASC"
DESC = "DESC"
-class AccountType(str, Enum, metaclass=ReprEnumMeta):
+class AccountType(StrEnum, metaclass=ReprEnumMeta):
# Revenue from BP payment commission
BP_COMMISSION = "bp_commission"
# BP wallets (owed balance)
@@ -83,7 +83,7 @@ class AccountType(str, Enum, metaclass=ReprEnumMeta):
WA_CREDIT_LINE = "wa_credit_line"
-class TransactionMetadataColumns(str, Enum):
+class TransactionMetadataColumns(StrEnum):
BONUS = "bonus_id"
# Note: EVENT & EVENT2 represent the same concept. I accidentally made
# this inconsistent.
@@ -102,7 +102,7 @@ class TransactionMetadataColumns(str, Enum):
CONTEST = "contest"
-class TransactionType(str, Enum):
+class TransactionType(StrEnum):
"""These are used in the Ledger to annotate the type of transaction (in
metadata: tx_type)
"""
diff --git a/generalresearch/models/thl/offerwall/__init__.py b/generalresearch/models/thl/offerwall/__init__.py
index 3acc592..e7c8e03 100644
--- a/generalresearch/models/thl/offerwall/__init__.py
+++ b/generalresearch/models/thl/offerwall/__init__.py
@@ -3,7 +3,7 @@ from __future__ import annotations
import hashlib
import json
from decimal import Decimal
-from enum import Enum
+from enum import StrEnum
from typing import Any, Literal, Self
from pydantic import (
@@ -31,7 +31,7 @@ from generalresearch.models.thl.product import (
from generalresearch.models.thl.user import User
-class OfferWallType(str, Enum):
+class OfferWallType(StrEnum):
"""
The specific offerwall type
"""
@@ -56,7 +56,7 @@ class OfferWallType(str, Enum):
STARWALL = "b59a2d2b"
-class OfferWallTypeClass(str, Enum):
+class OfferWallTypeClass(StrEnum):
"""
A higher level "class" to organize similar offerwall types.
For e.g. STARWALL_PLUS_BLOCK, STARWALL_PLUS, STARWALL all use the same
diff --git a/generalresearch/models/thl/product.py b/generalresearch/models/thl/product.py
index 8377e45..5b7ab9a 100644
--- a/generalresearch/models/thl/product.py
+++ b/generalresearch/models/thl/product.py
@@ -8,7 +8,7 @@ import warnings
from collections import defaultdict
from collections.abc import Callable
from decimal import Decimal
-from enum import Enum
+from enum import StrEnum
from functools import cached_property, partial
from typing import (
TYPE_CHECKING,
@@ -628,13 +628,13 @@ class SourceConfig(BaseModel):
)
-class Scope(str, Enum):
+class Scope(StrEnum):
GLOBAL = "global"
TEAM = "team"
PRODUCT = "product"
-class IntegrationMode(str, Enum):
+class IntegrationMode(StrEnum):
# We handle integration, get paid
PLATFORM = "platform"
# "external" credentials, we do not get paid for this activity
diff --git a/generalresearch/models/thl/profiling/upk_property.py b/generalresearch/models/thl/profiling/upk_property.py
index 9e78692..e46e00a 100644
--- a/generalresearch/models/thl/profiling/upk_property.py
+++ b/generalresearch/models/thl/profiling/upk_property.py
@@ -1,6 +1,6 @@
from __future__ import annotations
-from enum import Enum
+from enum import StrEnum
from functools import cached_property
from uuid import uuid4
@@ -11,7 +11,7 @@ from generalresearch.models.thl.category import Category
from generalresearch.utils.enum import ReprEnumMeta
-class PropertyType(str, Enum, metaclass=ReprEnumMeta):
+class PropertyType(StrEnum, metaclass=ReprEnumMeta):
# UserProfileKnowledge Item
UPK_ITEM = "i"
# UserProfileKnowledge Numerical
@@ -25,7 +25,7 @@ class PropertyType(str, Enum, metaclass=ReprEnumMeta):
# UPK_DATE = "d"
-class Cardinality(str, Enum, metaclass=ReprEnumMeta):
+class Cardinality(StrEnum, metaclass=ReprEnumMeta):
# Zero or More
ZERO_OR_MORE = "*"
# Zero or One
diff --git a/generalresearch/models/thl/profiling/upk_question.py b/generalresearch/models/thl/profiling/upk_question.py
index 78f9511..08ea350 100644
--- a/generalresearch/models/thl/profiling/upk_question.py
+++ b/generalresearch/models/thl/profiling/upk_question.py
@@ -3,9 +3,9 @@ from __future__ import annotations
import hashlib
import json
import re
-from enum import Enum
+from enum import StrEnum
from functools import cached_property
-from typing import Annotated, Any, List, Literal, Union
+from typing import Annotated, Any, Literal
from pydantic import (
BaseModel,
@@ -98,7 +98,7 @@ class UpkQuestionChoiceOut(UpkQuestionChoice):
# importance: Optional[UPKImportance] = Field(default=None, exclude=True)
-class UpkQuestionType(str, Enum):
+class UpkQuestionType(StrEnum):
# The question has options that the user must select from. A MC question
# can be e.g. Selector.SINGLE_ANSWER or Selector.MULTIPLE_ANSWER to
# indicate only 1 or more than 1 option can be selected respectively.
@@ -111,7 +111,7 @@ class UpkQuestionType(str, Enum):
HIDDEN = "HIDDEN"
-class UpkQuestionSelector(str, Enum):
+class UpkQuestionSelector(StrEnum):
pass
diff --git a/generalresearch/models/thl/supplier_tag.py b/generalresearch/models/thl/supplier_tag.py
index ad84c9b..739b895 100644
--- a/generalresearch/models/thl/supplier_tag.py
+++ b/generalresearch/models/thl/supplier_tag.py
@@ -1,7 +1,7 @@
-from enum import Enum
+from enum import StrEnum
-class SupplierTag(str, Enum):
+class SupplierTag(StrEnum):
"""Available tags which can be used to annotate supplier traffic
Note: should not include commas!
diff --git a/generalresearch/models/thl/survey/__init__.py b/generalresearch/models/thl/survey/__init__.py
index d6ba895..bc3d699 100644
--- a/generalresearch/models/thl/survey/__init__.py
+++ b/generalresearch/models/thl/survey/__init__.py
@@ -3,7 +3,6 @@ from __future__ import annotations
from abc import ABC, abstractmethod
from decimal import Decimal
from itertools import product
-from typing import Type
from more_itertools import flatten
from pydantic import BaseModel, Field
diff --git a/generalresearch/models/thl/user_quality_event.py b/generalresearch/models/thl/user_quality_event.py
index 52903e3..cfb4ff3 100644
--- a/generalresearch/models/thl/user_quality_event.py
+++ b/generalresearch/models/thl/user_quality_event.py
@@ -1,8 +1,8 @@
from __future__ import annotations
-from datetime import UTC, datetime, timezone
+from datetime import UTC, datetime
from decimal import Decimal
-from enum import Enum
+from enum import StrEnum
from typing import Literal
from pydantic import BaseModel, Field, PositiveInt
@@ -18,7 +18,7 @@ Typically used internally. These affect a user's quality standing.
"""
-class QualityEventType(str, Enum, metaclass=ReprEnumMeta):
+class QualityEventType(StrEnum, metaclass=ReprEnumMeta):
"""
Currently, the grpc call SendUserQualityEvents handles both the
recons/task adj, access control, and "security/hash failure" events.
diff --git a/generalresearch/models/thl/user_streak.py b/generalresearch/models/thl/user_streak.py
index 278809b..cc4d643 100644
--- a/generalresearch/models/thl/user_streak.py
+++ b/generalresearch/models/thl/user_streak.py
@@ -1,7 +1,8 @@
from __future__ import annotations
from datetime import date, datetime, timedelta
-from enum import Enum
+from enum import StrEnum
+from zoneinfo import ZoneInfo
import pandas as pd
from pydantic import (
@@ -15,14 +16,13 @@ from pydantic import (
model_validator,
)
from pydantic.json_schema import SkipJsonSchema
-from zoneinfo import ZoneInfo
from generalresearch.managers.leaderboard import country_timezone
from generalresearch.models import MAX_INT32
from generalresearch.models.thl.locales import CountryISO
-class StreakPeriod(str, Enum):
+class StreakPeriod(StrEnum):
# Midnight to midnight in the tz associated with the user's country
DAY = "day"
# Sunday midnight - sunday midnight
@@ -31,7 +31,7 @@ class StreakPeriod(str, Enum):
MONTH = "month"
-class StreakFulfillment(str, Enum):
+class StreakFulfillment(StrEnum):
"""
What has to happen for a user to fulfill a period for a streak
"""
@@ -42,7 +42,7 @@ class StreakFulfillment(str, Enum):
COMPLETE = "complete"
-class StreakState(str, Enum):
+class StreakState(StrEnum):
# The activity for today was completed!
ACTIVE = "active"
# They had activity yesterday, but not today, and can still continue today
diff --git a/generalresearch/models/thl/userhealth.py b/generalresearch/models/thl/userhealth.py
index fb15572..f0b7473 100644
--- a/generalresearch/models/thl/userhealth.py
+++ b/generalresearch/models/thl/userhealth.py
@@ -1,8 +1,8 @@
from __future__ import annotations
-from datetime import UTC, datetime, timezone
+from datetime import UTC, datetime
from enum import Enum
-from typing import Dict, Optional, Self
+from typing import Self
from pydantic import BaseModel, Field, NonNegativeFloat, PositiveInt
diff --git a/generalresearch/models/thl/wallet/__init__.py b/generalresearch/models/thl/wallet/__init__.py
index 1403ddf..2d1eb8d 100644
--- a/generalresearch/models/thl/wallet/__init__.py
+++ b/generalresearch/models/thl/wallet/__init__.py
@@ -1,9 +1,9 @@
-from enum import Enum
+from enum import StrEnum
from generalresearch.utils.enum import ReprEnumMeta
-class PayoutType(str, Enum, metaclass=ReprEnumMeta):
+class PayoutType(StrEnum, metaclass=ReprEnumMeta):
"""
The method in which the requested payout is delivered.
"""
@@ -35,7 +35,7 @@ class PayoutType(str, Enum, metaclass=ReprEnumMeta):
AMT_ASSIGNMENT = "AMT_ASSIGNMENT"
-class Currency(str, Enum):
+class Currency(StrEnum):
# United States Dollar
USD = "USD"
# Canadian Dollar
diff --git a/generalresearch/models/thl/wallet/cashout_method.py b/generalresearch/models/thl/wallet/cashout_method.py
index 4757eba..40c4717 100644
--- a/generalresearch/models/thl/wallet/cashout_method.py
+++ b/generalresearch/models/thl/wallet/cashout_method.py
@@ -2,9 +2,9 @@ from __future__ import annotations
import hashlib
import logging
-from datetime import datetime, timezone, UTC
-from enum import Enum
-from typing import Any, Literal
+from datetime import UTC, datetime
+from enum import StrEnum
+from typing import Any, Literal, Self
from pydantic import (
BaseModel,
@@ -16,7 +16,6 @@ from pydantic import (
field_validator,
model_validator,
)
-from typing import Self
from generalresearch.currency import USDCent
from generalresearch.models.custom_types import (
@@ -144,9 +143,7 @@ class CashoutMethod(CashoutMethodBase):
"a user may have a paypal cashout method with their paypal"
"email associated.",
)
- last_updated: AwareDatetimeISO = Field(
- default_factory=lambda: datetime.now(tz=UTC)
- )
+ last_updated: AwareDatetimeISO = Field(default_factory=lambda: datetime.now(tz=UTC))
is_live: bool = Field(default=True)
@model_validator(mode="after")
@@ -249,7 +246,7 @@ class CashoutMethodsResponse(StatusResponse):
cashout_methods: list[CashoutMethodOut] = Field()
-class DeliveryStatus(str, Enum):
+class DeliveryStatus(StrEnum):
PENDING = "Pending"
SHIPPED = "Shipped"
IN_TRANSIT = "In Transit"
@@ -261,14 +258,14 @@ class DeliveryStatus(str, Enum):
LOST = "Lost"
-class ShippingCarrier(str, Enum):
+class ShippingCarrier(StrEnum):
USPS = "USPS"
FEDEX = "FedEx"
UPS = "UPS"
DHL = "DHL"
-class ShippingMethod(str, Enum):
+class ShippingMethod(StrEnum):
STANDARD = "Standard"
EXPRESS = "Express"
TWO_DAY = "Two-Day"
@@ -394,7 +391,7 @@ example_foreign_value = {
}
-class RedemptionCurrency(str, Enum, metaclass=ReprEnumMeta):
+class RedemptionCurrency(StrEnum, metaclass=ReprEnumMeta):
"""
Supported Currencies for Foreign Redemptions
"""