artemis-model 0.1.115__py3-none-any.whl → 0.1.117__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- artemis_model/banned_tracks.py +4 -1
- artemis_model/redis/__init__.py +4 -1
- artemis_model/redis/bucket.py +7 -19
- artemis_model/redis/play_history.py +3 -8
- artemis_model/redis/zone_state.py +55 -9
- artemis_model/zone_activity.py +2 -0
- {artemis_model-0.1.115.dist-info → artemis_model-0.1.117.dist-info}/METADATA +1 -1
- {artemis_model-0.1.115.dist-info → artemis_model-0.1.117.dist-info}/RECORD +9 -9
- {artemis_model-0.1.115.dist-info → artemis_model-0.1.117.dist-info}/WHEEL +0 -0
artemis_model/banned_tracks.py
CHANGED
@@ -6,16 +6,19 @@ from artemis_model.base import AuditMixin, TimeStampMixin, CustomSyncBase, Custo
|
|
6
6
|
|
7
7
|
|
8
8
|
class BannedTracksMixin(TimeStampMixin, AuditMixin):
|
9
|
-
"""Banned Tracks per Zone Model"""
|
9
|
+
"""Banned Tracks per Zone Model"""
|
10
|
+
|
10
11
|
zone_id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
11
12
|
track_id: Mapped[UUID] = mapped_column(UUID(as_uuid=True), primary_key=True)
|
12
13
|
|
13
14
|
|
14
15
|
class BannedTracksSync(CustomSyncBase, BannedTracksMixin):
|
15
16
|
"""Banned Tracks per Zone Model"""
|
17
|
+
|
16
18
|
pass
|
17
19
|
|
18
20
|
|
19
21
|
class BannedTracks(CustomBase, BannedTracksMixin):
|
20
22
|
"""Banned Tracks per Zone Model"""
|
23
|
+
|
21
24
|
pass
|
artemis_model/redis/__init__.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"""Redis models."""
|
2
2
|
|
3
|
-
from .zone_state import ZoneState, NowPlaying, SessionId, BucketId
|
3
|
+
from .zone_state import ZoneState, NowPlaying, SessionId, BucketId, PushedPlaylist, PushedPlaylistMetadata, PushedPlaylistDetails
|
4
4
|
from .device import ActiveDevice
|
5
5
|
from .bucket import RedisTrackBucketItem
|
6
6
|
from .play_history import RedisTrackPlayHistoryItem
|
@@ -19,6 +19,9 @@ __all__ = [
|
|
19
19
|
"SessionId",
|
20
20
|
"BucketId",
|
21
21
|
"ActiveDevice",
|
22
|
+
"PushedPlaylist",
|
23
|
+
"PushedPlaylistMetadata",
|
24
|
+
"PushedPlaylistDetails",
|
22
25
|
"KEY_ZONE_PLAY_HISTORY_TEMPLATE",
|
23
26
|
"KEY_ZONE_PUSH_PLAYLIST_BUCKET_TEMPLATE",
|
24
27
|
"KEY_ZONE_SCHEDULE_BUCKET_TEMPLATE",
|
artemis_model/redis/bucket.py
CHANGED
@@ -1,25 +1,16 @@
|
|
1
1
|
"""Redis track buckets"""
|
2
|
-
|
2
|
+
|
3
3
|
from pydantic import BaseModel, Field, ConfigDict
|
4
4
|
from typing import Annotated
|
5
5
|
from datetime import datetime, timezone
|
6
6
|
import uuid
|
7
7
|
|
8
8
|
|
9
|
-
TrackId = Annotated[
|
10
|
-
uuid.UUID,
|
11
|
-
Field(description="Track ID (UUID)")
|
12
|
-
]
|
9
|
+
TrackId = Annotated[uuid.UUID, Field(description="Track ID (UUID)")]
|
13
10
|
|
14
|
-
PlaylistId = Annotated[
|
15
|
-
int,
|
16
|
-
Field(description="Playlist ID (integer)")
|
17
|
-
]
|
11
|
+
PlaylistId = Annotated[int, Field(description="Playlist ID (integer)")]
|
18
12
|
|
19
|
-
Timestamp = Annotated[
|
20
|
-
int,
|
21
|
-
Field(description="Unix timestamp")
|
22
|
-
]
|
13
|
+
Timestamp = Annotated[int, Field(description="Unix timestamp")]
|
23
14
|
|
24
15
|
|
25
16
|
class RedisTrackBucketItem(BaseModel):
|
@@ -34,10 +25,7 @@ class RedisTrackBucketItem(BaseModel):
|
|
34
25
|
playlist_id: PlaylistId
|
35
26
|
ts: Timestamp = Field(default_factory=lambda: int(datetime.now(timezone.utc).timestamp()))
|
36
27
|
|
37
|
-
model_config = ConfigDict(
|
38
|
-
json_encoders={uuid.UUID: str},
|
39
|
-
populate_by_name=True
|
40
|
-
)
|
28
|
+
model_config = ConfigDict(json_encoders={uuid.UUID: str}, populate_by_name=True)
|
41
29
|
|
42
30
|
def as_redis_entry(self) -> dict[str, int]:
|
43
31
|
"""
|
@@ -46,8 +34,7 @@ class RedisTrackBucketItem(BaseModel):
|
|
46
34
|
"""
|
47
35
|
key = self.model_dump_json(include={"track_id", "playlist_id"})
|
48
36
|
return {key: self.ts}
|
49
|
-
|
50
|
-
|
37
|
+
|
51
38
|
@classmethod
|
52
39
|
def from_redis_entry(cls, entry: dict[str, int]) -> "RedisTrackBucketItem":
|
53
40
|
"""
|
@@ -58,5 +45,6 @@ class RedisTrackBucketItem(BaseModel):
|
|
58
45
|
|
59
46
|
class RedisTrackBucketItemValue(BaseModel):
|
60
47
|
"""JSON string format for Redis keys: '{"track_id": "...", "playlist_id": ...}'"""
|
48
|
+
|
61
49
|
track_id: TrackId
|
62
50
|
playlist_id: PlaylistId
|
@@ -5,15 +5,9 @@ from typing import Annotated
|
|
5
5
|
from datetime import datetime, timezone
|
6
6
|
|
7
7
|
|
8
|
-
TrackId = Annotated[
|
9
|
-
str,
|
10
|
-
Field(description="Track ID (UUID or string)")
|
11
|
-
]
|
8
|
+
TrackId = Annotated[str, Field(description="Track ID (UUID or string)")]
|
12
9
|
|
13
|
-
Timestamp = Annotated[
|
14
|
-
int,
|
15
|
-
Field(description="Unix timestamp")
|
16
|
-
]
|
10
|
+
Timestamp = Annotated[int, Field(description="Unix timestamp")]
|
17
11
|
|
18
12
|
|
19
13
|
class RedisTrackPlayHistoryItem(BaseModel):
|
@@ -21,6 +15,7 @@ class RedisTrackPlayHistoryItem(BaseModel):
|
|
21
15
|
Represents the value stored in Redis sorted set:
|
22
16
|
A string like "track_id#timestamp"
|
23
17
|
"""
|
18
|
+
|
24
19
|
track_id: TrackId
|
25
20
|
ts: Timestamp = Field(default_factory=lambda: int(datetime.now(timezone.utc).timestamp()))
|
26
21
|
|
@@ -27,6 +27,50 @@ BucketId = Annotated[
|
|
27
27
|
]
|
28
28
|
|
29
29
|
|
30
|
+
class PushedPlaylist(BaseModel):
|
31
|
+
"""Pushed playlist schema."""
|
32
|
+
|
33
|
+
id: int = Field(
|
34
|
+
description="The id of the pushed playlist. It's generated as a timestamp value of the current time."
|
35
|
+
)
|
36
|
+
name: str = Field(
|
37
|
+
description="The name of the pushed playlist",
|
38
|
+
)
|
39
|
+
|
40
|
+
|
41
|
+
class PushedPlaylistMetadata(BaseModel):
|
42
|
+
"""Pushed playlist metadata schema."""
|
43
|
+
|
44
|
+
expire_at: int = Field(
|
45
|
+
description="The expire time of the pushed playlist. It's calculated in set_bucket_track as the timestamp value of the timeslot."
|
46
|
+
)
|
47
|
+
playlists: list[PushedPlaylist] = Field(
|
48
|
+
description="The playlists of the pushed playlist",
|
49
|
+
)
|
50
|
+
|
51
|
+
|
52
|
+
class PushedPlaylistDetails(BaseModel):
|
53
|
+
"""Player details schema."""
|
54
|
+
|
55
|
+
redis_details: dict[SessionId, BucketId] | None = Field(
|
56
|
+
default_factory=dict,
|
57
|
+
description="""Pushed playlists does exist in Redis with a timestamp.
|
58
|
+
Example: zone_{zone_id}_pp_bucket_{ts}
|
59
|
+
Every pushplaylist action has a session id. Here we map these session ids to the bucket id.
|
60
|
+
""",
|
61
|
+
)
|
62
|
+
metadata: PushedPlaylistMetadata | None = Field(
|
63
|
+
default=None,
|
64
|
+
description="The metadata of the pushed playlist",
|
65
|
+
)
|
66
|
+
|
67
|
+
@field_validator("redis_details", mode="before")
|
68
|
+
@classmethod
|
69
|
+
def default_empty_dict_if_none(cls, v):
|
70
|
+
"""Override none value to empty dict."""
|
71
|
+
return v or {}
|
72
|
+
|
73
|
+
|
30
74
|
class ZoneState(BaseModel):
|
31
75
|
"""Zone state schema."""
|
32
76
|
|
@@ -42,16 +86,18 @@ class ZoneState(BaseModel):
|
|
42
86
|
default=None,
|
43
87
|
description="The currently playing track",
|
44
88
|
)
|
45
|
-
|
46
|
-
|
89
|
+
pp_details: PushedPlaylistDetails | None = Field(
|
90
|
+
default=None,
|
47
91
|
description="The details of the pushed playlist",
|
48
92
|
)
|
49
93
|
|
50
|
-
@field_validator("push_playlist_details", mode="before")
|
51
|
-
@classmethod
|
52
|
-
def default_empty_dict_if_none(cls, v):
|
53
|
-
"""Override none value to empty dict."""
|
54
|
-
return v or {}
|
55
|
-
|
56
94
|
|
57
|
-
__all__ = [
|
95
|
+
__all__ = [
|
96
|
+
"ZoneState",
|
97
|
+
"NowPlaying",
|
98
|
+
"SessionId",
|
99
|
+
"BucketId",
|
100
|
+
"PushedPlaylist",
|
101
|
+
"PushedPlaylistMetadata",
|
102
|
+
"PushedPlaylistDetails",
|
103
|
+
]
|
artemis_model/zone_activity.py
CHANGED
@@ -39,9 +39,11 @@ class PlayerActivityMixin(TimeStampMixin, AuditMixin):
|
|
39
39
|
|
40
40
|
class PlayerActivitySync(CustomSyncBase, PlayerActivityMixin):
|
41
41
|
"""Sync model for Player Activity"""
|
42
|
+
|
42
43
|
pass
|
43
44
|
|
44
45
|
|
45
46
|
class PlayerActivity(CustomBase, PlayerActivityMixin):
|
46
47
|
"""Base model for Player Activity"""
|
48
|
+
|
47
49
|
pass
|
@@ -2,7 +2,7 @@ artemis_model/__init__.py,sha256=zEeAUndIbJdp_M6pFlON_BEehnMaMcTvusijGktpnvk,792
|
|
2
2
|
artemis_model/album.py,sha256=9uw9HVNHVBjl-0Dgv-o5MHXhUPwedvbnbzzY3A1cKQg,2077
|
3
3
|
artemis_model/artist.py,sha256=vjXlFN2mOEidAzUzxmsAP5GnVTvJUuhFdhQaH214lgw,1563
|
4
4
|
artemis_model/auth.py,sha256=0Yg_6N1nj4U31F86u1PE0leIa3D64QlYrsDlavulN6s,4033
|
5
|
-
artemis_model/banned_tracks.py,sha256=
|
5
|
+
artemis_model/banned_tracks.py,sha256=uU-F-6DL2EshPAUwLTTHjYZ7UEz4vm0Wfcif2F0lSKw,664
|
6
6
|
artemis_model/base.py,sha256=zC20m8a1Sa11oEY0ay1iIRQeybGYvXY5p3Vr-pxoKnQ,6802
|
7
7
|
artemis_model/category.py,sha256=jhCZrK-LxPmc0pXmVifAZWdCENssBTzdTmC3nqqZc6s,1761
|
8
8
|
artemis_model/dj_set.py,sha256=fOYnCu4n5TiqyiSojfdFnO7LuPe_mM2SUwBV5xHy2Kc,3782
|
@@ -13,12 +13,12 @@ artemis_model/organization.py,sha256=yjGHJLTOtb9PUfxSPal782Rceb8xb8vftXX67tHRNqc
|
|
13
13
|
artemis_model/otp.py,sha256=guIRGtyFlHUBthCAEsTh5_Hs-1yiGN_qfEO4uHNcv4s,1017
|
14
14
|
artemis_model/permission.py,sha256=Bn1Bg1aCS4Z4_3tqEqvtrzqAYDCImsvmGyIEMoVycEk,1452
|
15
15
|
artemis_model/playlist.py,sha256=L22KSJgTZmNEc9CqM3TFD4Wnx3TW77GQJ5EFLJCxZ20,6393
|
16
|
-
artemis_model/redis/__init__.py,sha256=
|
17
|
-
artemis_model/redis/bucket.py,sha256=
|
16
|
+
artemis_model/redis/__init__.py,sha256=l-Y8QgvQPSVQKI6sq-Gq-3ypb5KCT8eSYHqG_AHzqFQ,925
|
17
|
+
artemis_model/redis/bucket.py,sha256=DlmIf6GxfKq9CzcXmMx5IcviaqOTvuWwIb6lAVcZQGs,1537
|
18
18
|
artemis_model/redis/device.py,sha256=ZUiIyVmtWiEwayFIg9mktiFaVuHQ7Fg0rvSjjWyryCI,484
|
19
19
|
artemis_model/redis/keys.py,sha256=bnlSaBCIakLCIlgTr8BlYJmKEtKKvtdr43QIJCLnc90,567
|
20
|
-
artemis_model/redis/play_history.py,sha256=
|
21
|
-
artemis_model/redis/zone_state.py,sha256=
|
20
|
+
artemis_model/redis/play_history.py,sha256=Jm0guS0UZDxfCXeWJ8vqcjjl93W_EeC7XcBXcclKPiE,1259
|
21
|
+
artemis_model/redis/zone_state.py,sha256=F0-nAS6zGQ6-qy5AInG3AayYdaPHnk7jyax-Q2G-1sY,2993
|
22
22
|
artemis_model/schedule.py,sha256=CkLHWz-BwvUY2EQCfoU4SymgCariPzoQdtRLITqBPmk,2451
|
23
23
|
artemis_model/setting.py,sha256=EWzOmE31mLNWwmV_wmqttHPMycvQZW7SJUIozF2b8bo,1190
|
24
24
|
artemis_model/sqs/__init__.py,sha256=nHpXQns64qQ5Cqjyo6w9fDGO_wWhprqn1bhKf3eWnio,17
|
@@ -26,7 +26,7 @@ artemis_model/sqs/messages.py,sha256=mT8Q2OmrX5E3XUYIC-QBOAGPm4nuuWZa4CgFtCOOuwM
|
|
26
26
|
artemis_model/track.py,sha256=QwUF0QKVn1I64648B-NI75-IzGQvnLt9B0emD4GnS6E,3757
|
27
27
|
artemis_model/user.py,sha256=eqIdCiBJRNLjCwPPCn-gQ6si0O5JUBGfp9oWJL5zVW4,2131
|
28
28
|
artemis_model/zone.py,sha256=iGRUtzUwKh9LHT3MOfzzg1DnkPBts_ZBzZVTi2EmIgs,2282
|
29
|
-
artemis_model/zone_activity.py,sha256=
|
30
|
-
artemis_model-0.1.
|
31
|
-
artemis_model-0.1.
|
32
|
-
artemis_model-0.1.
|
29
|
+
artemis_model/zone_activity.py,sha256=IkB1Ggjb24-FXAd4pSOeyhngX54U9OtTdFTvm4DYL1A,1600
|
30
|
+
artemis_model-0.1.117.dist-info/METADATA,sha256=TAsFcmB-M6meE6-biygV1CMsWfJfl7WK22y9Id0H8nE,3445
|
31
|
+
artemis_model-0.1.117.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
32
|
+
artemis_model-0.1.117.dist-info/RECORD,,
|
File without changes
|