feat(core): implement domain dataclasses for issue #5 #19
@@ -23,16 +23,12 @@ class Bounty:
|
|||||||
class TrackedBounty:
|
class TrackedBounty:
|
||||||
"""A bounty that a user is tracking.
|
"""A bounty that a user is tracking.
|
||||||
|
han marked this conversation as resolved
Outdated
|
|||||||
|
|
||||||
Use TrackedBounty when you need to record that a user is tracking a specific
|
Lightweight relation/pointer - the actual tracking context (including room)
|
||||||
bounty from a specific room. The room_id indicates which room the bounty
|
lives in TrackingData, not here.
|
||||||
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
|
bounty_id: int
|
||||||
created_at: int
|
created_at: int
|
||||||
room_id: int
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -50,16 +46,16 @@ class RoomData:
|
|||||||
|
|
||||||
|
han marked this conversation as resolved
Outdated
han
commented
what is this next_id refers to? what is this next_id refers to?
|
|||||||
@dataclass
|
@dataclass
|
||||||
|
han marked this conversation as resolved
Outdated
han
commented
I dont understand the difference of TrackingData and TrackedBounty. when to use which? I dont understand the difference of TrackingData and TrackedBounty. when to use which?
|
|||||||
class TrackingData:
|
class TrackingData:
|
||||||
"""User tracking state within a group.
|
"""User tracking state within a room (group or DM).
|
||||||
|
|
||||||
|
han marked this conversation as resolved
Outdated
han
commented
in the tracking data, why there is no grouip id? in a way how do we know this tracking is for user in which group? in the tracking data, why there is no grouip id? in a way how do we know this tracking is for user in which group?
|
|||||||
TrackingData vs TrackedBounty:
|
TrackingData vs TrackedBounty:
|
||||||
- Use TrackingData to store ALL tracked bounties for a user in a specific group.
|
- Use TrackingData to store ALL tracked bounties for a user in a specific room.
|
||||||
It contains the group_id, user_id, and a list of TrackedBounty entries.
|
It contains the room_id, user_id, and a list of TrackedBounty entries.
|
||||||
- Use TrackedBounty to represent a single tracked bounty entry within that list.
|
- Use TrackedBounty to represent a single tracked bounty entry within that list.
|
||||||
|
|
||||||
TrackingData is the container, TrackedBounty is the item.
|
TrackingData is the container, TrackedBounty is the item.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
han marked this conversation as resolved
Outdated
han
commented
is it possible to combine both UserData and GroupData? since their attributes are similar as well. we can name it maybe like RoomData? it sounds too specific to telegram, but that is the bigger picture. so we used the room_id. and makes sure it can be minus as well because telegram's id for group has minus in it. if we can't do that maybe we can add attribute like is this group or personal. is that makes sense? is it possible to combine both UserData and GroupData? since their attributes are similar as well. we can name it maybe like RoomData? it sounds too specific to telegram, but that is the bigger picture. so we used the room_id. and makes sure it can be minus as well because telegram's id for group has minus in it. if we can't do that maybe we can add attribute like is this group or personal. is that makes sense?
|
|||||||
group_id: int
|
room_id: int
|
||||||
user_id: int
|
user_id: int
|
||||||
tracked: list[TrackedBounty]
|
tracked: list[TrackedBounty]
|
||||||
|
|||||||
@@ -83,14 +83,13 @@ class TestBounty:
|
|||||||
|
|
||||||
class TestTrackedBounty:
|
class TestTrackedBounty:
|
||||||
def test_create_tracked_bounty(self):
|
def test_create_tracked_bounty(self):
|
||||||
tb = TrackedBounty(bounty_id=5, created_at=1735600000, room_id=-1001)
|
tb = TrackedBounty(bounty_id=5, created_at=1735600000)
|
||||||
assert tb.bounty_id == 5
|
assert tb.bounty_id == 5
|
||||||
assert tb.created_at == 1735600000
|
assert tb.created_at == 1735600000
|
||||||
assert tb.room_id == -1001
|
|
||||||
|
|
||||||
def test_tracked_bounty_comparison(self):
|
def test_tracked_bounty_comparison(self):
|
||||||
tb1 = TrackedBounty(bounty_id=1, created_at=0, room_id=-1001)
|
tb1 = TrackedBounty(bounty_id=1, created_at=0)
|
||||||
tb2 = TrackedBounty(bounty_id=1, created_at=0, room_id=-1001)
|
tb2 = TrackedBounty(bounty_id=1, created_at=0)
|
||||||
assert tb1 == tb2
|
assert tb1 == tb2
|
||||||
|
|
||||||
|
|
||||||
@@ -132,13 +131,13 @@ class TestRoomData:
|
|||||||
|
|
||||||
class TestTrackingData:
|
class TestTrackingData:
|
||||||
def test_create_tracking_data(self):
|
def test_create_tracking_data(self):
|
||||||
td = TrackingData(group_id=-1001, user_id=123456, tracked=[])
|
td = TrackingData(room_id=-1001, user_id=123456, tracked=[])
|
||||||
assert td.group_id == -1001
|
assert td.room_id == -1001
|
||||||
assert td.user_id == 123456
|
assert td.user_id == 123456
|
||||||
assert td.tracked == []
|
assert td.tracked == []
|
||||||
|
|
||||||
def test_tracking_data_with_tracked(self):
|
def test_tracking_data_with_tracked(self):
|
||||||
tb = TrackedBounty(bounty_id=5, created_at=0, room_id=-1001)
|
tb = TrackedBounty(bounty_id=5, created_at=0)
|
||||||
td = TrackingData(group_id=-1001, user_id=123, tracked=[tb])
|
td = TrackingData(room_id=-1001, user_id=123, tracked=[tb])
|
||||||
assert len(td.tracked) == 1
|
assert len(td.tracked) == 1
|
||||||
assert td.tracked[0].bounty_id == 5
|
assert td.tracked[0].bounty_id == 5
|
||||||
|
|||||||
Reference in New Issue
Block a user
we should also add room_id in this trackedbounty to know where the user is tracking the bounty from. to show their list track bounties depends on the room