Address PR #19 review feedback round 2:
- Bounty.created_by_user_id is now non-optional (always required) - Removed is_group from RoomData (negative room_id is self-documenting) - Added room_id to TrackedBounty to track which room bounty was tracked from - Added clarifying docstrings explaining TrackingData vs TrackedBounty - Updated tests to match new model structure
This commit is contained in:
@@ -1,53 +1,63 @@
|
||||
"""Domain dataclasses for JIGAIDO bounty tracker."""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
|
||||
|
||||
@dataclass
|
||||
class Bounty:
|
||||
"""Bounty - used for both group and personal bounties.
|
||||
"""A bounty created by a user.
|
||||
|
||||
Use created_by_user_id to distinguish: if set, it's a group bounty
|
||||
created by that user. If None, it's a personal/DM bounty.
|
||||
The created_by_user_id field always refers to the user who created the bounty.
|
||||
It does NOT indicate whether the bounty is a group or personal bounty.
|
||||
"""
|
||||
|
||||
id: int
|
||||
text: Optional[str]
|
||||
link: Optional[str]
|
||||
due_date_ts: Optional[int]
|
||||
text: str | None
|
||||
link: str | None
|
||||
due_date_ts: int | None
|
||||
created_at: int
|
||||
created_by_user_id: Optional[int] = None
|
||||
created_by_user_id: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class TrackedBounty:
|
||||
"""A bounty that a user is tracking."""
|
||||
"""A bounty that a user is tracking.
|
||||
|
||||
Use TrackedBounty when you need to record that a user is tracking a specific
|
||||
bounty from a specific room. The room_id indicates which room the bounty
|
||||
was tracked from (useful when users can track bounties across multiple rooms).
|
||||
|
||||
For simple tracking lists, just use bounty_id and created_at.
|
||||
"""
|
||||
|
||||
bounty_id: int
|
||||
created_at: int
|
||||
room_id: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class RoomData:
|
||||
"""All data for a room (group or DM).
|
||||
|
||||
For groups: is_group=True, room_id is negative (Telegram group ID)
|
||||
For DMs: is_group=False, room_id is the user_id (positive)
|
||||
next_id is used to generate unique bounty IDs within this room.
|
||||
The room_id can be negative for Telegram groups or positive for DMs.
|
||||
The next_id field is used to generate unique bounty IDs within this room.
|
||||
"""
|
||||
|
||||
room_id: int
|
||||
is_group: bool
|
||||
bounties: list[Bounty]
|
||||
next_id: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class TrackingData:
|
||||
"""User tracking data within a group.
|
||||
"""User tracking state within a group.
|
||||
|
||||
group_id is the Telegram group ID (always negative).
|
||||
TrackingData vs TrackedBounty:
|
||||
- Use TrackingData to store ALL tracked bounties for a user in a specific group.
|
||||
It contains the group_id, user_id, and a list of TrackedBounty entries.
|
||||
- Use TrackedBounty to represent a single tracked bounty entry within that list.
|
||||
|
||||
TrackingData is the container, TrackedBounty is the item.
|
||||
"""
|
||||
|
||||
group_id: int
|
||||
|
||||
Reference in New Issue
Block a user