Files
jigaido/core/models.py
shokollm f1ef33451c Address PR #19 review feedback: simplify models
- Remove GroupBounty/PersonalBounty subclasses, use Bounty with optional created_by_user_id
- Combine UserData/GroupData into RoomData with room_id and is_group fields
- Add group_id field to TrackingData (supports negative Telegram group IDs)
- Add test_bounty_comparison_not_equal for verifying different bounties are not equal
- Update core/__init__.py exports
2026-04-02 21:47:26 +00:00

56 lines
1.2 KiB
Python

"""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.
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.
"""
id: int
text: Optional[str]
link: Optional[str]
due_date_ts: Optional[int]
created_at: int
created_by_user_id: Optional[int] = None
@dataclass
class TrackedBounty:
"""A bounty that a user is tracking."""
bounty_id: int
created_at: 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.
"""
room_id: int
is_group: bool
bounties: list[Bounty]
next_id: int
@dataclass
class TrackingData:
"""User tracking data within a group.
group_id is the Telegram group ID (always negative).
"""
group_id: int
user_id: int
tracked: list[TrackedBounty]