artemis-model 0.1.163__py3-none-any.whl → 0.1.166__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.

Potentially problematic release.


This version of artemis-model might be problematic. Click here for more details.

artemis_model/__init__.py CHANGED
@@ -19,3 +19,4 @@ from artemis_model.zone import * # noqa
19
19
  from artemis_model.otp import * # noqa
20
20
  from artemis_model.banned_tracks import * # noqa
21
21
  from artemis_model.zone_activity import * # noqa
22
+ from artemis_model.zone_state import * # noqa
@@ -12,7 +12,6 @@ from .zone_state import (
12
12
  from .device import ActiveDevice
13
13
  from .bucket import RedisTrackBucketItem
14
14
  from .play_history import RedisTrackPlayHistoryItem
15
- from .user import hash_token
16
15
  from .keys import (
17
16
  KEY_ZONE_PLAY_HISTORY_TEMPLATE,
18
17
  KEY_ZONE_PUSH_PLAYLIST_BUCKET_TEMPLATE,
@@ -23,7 +22,6 @@ from .keys import (
23
22
 
24
23
 
25
24
  __all__ = [
26
- "hash_token",
27
25
  "ZoneState",
28
26
  "NowPlaying",
29
27
  "SessionId",
@@ -1,6 +1,5 @@
1
1
  """Redis keys."""
2
2
 
3
- KEY_USER_REFRESH_TOKEN_TEMPLATE = "user_{user_id}_rt"
4
3
  KEY_ZONE_ACTIVE_DEVICE_TEMPLATE = "zone_{zone_id}_active_devices"
5
4
  KEY_ZONE_PLAY_HISTORY_TEMPLATE = "zone_{zone_id}_play_history"
6
5
  KEY_ZONE_PUSH_PLAYLIST_BUCKET_TEMPLATE = "zone_{zone_id}_pp_bucket_{timeslot_ts}"
@@ -10,7 +9,6 @@ KEY_ZONE_STATE_TEMPLATE = "zone_{zone_id}_state"
10
9
 
11
10
 
12
11
  __all__ = [
13
- "KEY_USER_REFRESH_TOKEN_TEMPLATE",
14
12
  "KEY_ZONE_ACTIVE_DEVICE_TEMPLATE",
15
13
  "KEY_ZONE_PLAY_HISTORY_TEMPLATE",
16
14
  "KEY_ZONE_PUSH_PLAYLIST_BUCKET_TEMPLATE",
@@ -0,0 +1,86 @@
1
+ """Zone state data models."""
2
+
3
+ # models/zone_state.py
4
+
5
+ import uuid
6
+ from datetime import datetime
7
+ from typing import Optional
8
+
9
+ from sqlalchemy import UUID, DateTime, ForeignKey, Integer, String
10
+ from sqlalchemy.dialects.postgresql import JSONB
11
+ from sqlalchemy.orm import Mapped, mapped_column, relationship
12
+ from sqlalchemy.ext.declarative import declared_attr
13
+
14
+ from artemis_model.base import CustomSyncBase, TimeStampMixin, CustomBase
15
+
16
+
17
+ class ZoneStateMetaMixin(TimeStampMixin):
18
+ """
19
+ Rarely changing part of a zone's state.
20
+ One row per zone.
21
+ """
22
+
23
+ zone_id: Mapped[uuid.UUID] = mapped_column(
24
+ UUID(as_uuid=True),
25
+ ForeignKey("zone.id", ondelete="CASCADE"),
26
+ primary_key=True,
27
+ default=uuid.uuid4,
28
+ doc="Zone identifier (PK)",
29
+ )
30
+
31
+ player_mode: Mapped[str] = mapped_column(String, default="scheduled", nullable=False, index=True)
32
+ player_state: Mapped[str] = mapped_column(String, default="ready", nullable=False, index=True)
33
+ pp_details: Mapped[Optional[dict]] = mapped_column(JSONB, nullable=True)
34
+ schedule_details: Mapped[Optional[dict]] = mapped_column(JSONB, nullable=True)
35
+
36
+ @declared_attr
37
+ def now_playing(cls) -> Mapped["ZoneNowPlaying"]:
38
+ return relationship(
39
+ "ZoneNowPlaying",
40
+ back_populates="meta",
41
+ uselist=False,
42
+ cascade="all, delete-orphan",
43
+ )
44
+
45
+
46
+ class ZoneStateMetaSync(CustomSyncBase, ZoneStateMetaMixin):
47
+ pass
48
+
49
+
50
+ class ZoneStateMeta(CustomBase, ZoneStateMetaMixin):
51
+ pass
52
+
53
+
54
+ class ZoneNowPlayingMixin:
55
+ """
56
+ Frequently changing part of a zone's state.
57
+ Keep row narrow; PK-only index for cheap updates.
58
+ One row per zone (FK to ZoneStateMeta).
59
+ """
60
+
61
+ zone_id: Mapped[uuid.UUID] = mapped_column(
62
+ UUID(as_uuid=True),
63
+ ForeignKey("zone_state_meta.zone_id", ondelete="CASCADE"),
64
+ primary_key=True,
65
+ doc="Matches zone_state_meta.zone_id",
66
+ )
67
+
68
+ track_name: Mapped[Optional[str]] = mapped_column(String, nullable=True)
69
+ artist_name: Mapped[Optional[str]] = mapped_column(String, nullable=True)
70
+ album_name: Mapped[Optional[str]] = mapped_column(String, nullable=True)
71
+ playlist_id: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
72
+
73
+ # Lightweight timestamp for freshness; mirrors your style (see LoginHistory)
74
+ updated_at = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
75
+
76
+ @declared_attr
77
+ def meta(cls) -> Mapped["ZoneStateMeta"]:
78
+ return relationship("ZoneStateMeta", back_populates="now_playing")
79
+
80
+
81
+ class ZoneNowPlayingSync(CustomSyncBase, ZoneNowPlayingMixin):
82
+ pass
83
+
84
+
85
+ class ZoneNowPlaying(CustomBase, ZoneNowPlayingMixin):
86
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: artemis-model
3
- Version: 0.1.163
3
+ Version: 0.1.166
4
4
  Summary:
5
5
  Author: Jukeboxy
6
6
  Requires-Python: >=3.10.6,<4.0.0
@@ -1,4 +1,4 @@
1
- artemis_model/__init__.py,sha256=R__YcDg7FMAMHyy9CVjqi6fC58DEWkwMXCg0S9Az6Ck,981
1
+ artemis_model/__init__.py,sha256=zjzjYdT0t_8rCTCpDRJ0P4UKhVezRz10zUQnYOfd9WU,1028
2
2
  artemis_model/album.py,sha256=9uw9HVNHVBjl-0Dgv-o5MHXhUPwedvbnbzzY3A1cKQg,2077
3
3
  artemis_model/approved_playlist_list.py,sha256=JJ2n15JA7kBbsKrQA-GpfriMEjCHZmWcFhFAKfNcPxY,1869
4
4
  artemis_model/artist.py,sha256=vjXlFN2mOEidAzUzxmsAP5GnVTvJUuhFdhQaH214lgw,1563
@@ -16,12 +16,11 @@ artemis_model/organization_include_pal_setting.py,sha256=OhNRn4aH96IquJcJBsubvZE
16
16
  artemis_model/otp.py,sha256=guIRGtyFlHUBthCAEsTh5_Hs-1yiGN_qfEO4uHNcv4s,1017
17
17
  artemis_model/permission.py,sha256=Bn1Bg1aCS4Z4_3tqEqvtrzqAYDCImsvmGyIEMoVycEk,1452
18
18
  artemis_model/playlist.py,sha256=O60zlP1LrDkzNrrfNA7TD_kotd5A9i8PuFhwonXFhN0,6559
19
- artemis_model/redis/__init__.py,sha256=uagGPkaIkSsCqEFVMYj3kr8d7dWiBNCg0gqe_iqUdgI,991
19
+ artemis_model/redis/__init__.py,sha256=hwxNaoTAwFWJxHL6ijp5MOJkapWPv9PEPoY6rtUhCyI,944
20
20
  artemis_model/redis/bucket.py,sha256=DlmIf6GxfKq9CzcXmMx5IcviaqOTvuWwIb6lAVcZQGs,1537
21
21
  artemis_model/redis/device.py,sha256=MmCIpBmWxm80CHeZinAXYZOdtPE49xXLo9oRa4FyjcY,505
22
- artemis_model/redis/keys.py,sha256=B5QMZGLd8BCJLj4cLv3-tREKVhk8UJbufDahl80Xpuk,767
22
+ artemis_model/redis/keys.py,sha256=X5lvVJHeKHt0lJKhi5i8KzNtDGQ3TuGrjm3V2CcTgXw,674
23
23
  artemis_model/redis/play_history.py,sha256=Jm0guS0UZDxfCXeWJ8vqcjjl93W_EeC7XcBXcclKPiE,1259
24
- artemis_model/redis/user.py,sha256=nhaebEx9uaDZlu7KjfnvnUfGyxFPqc5w4kMbXkp63lI,183
25
24
  artemis_model/redis/zone_state.py,sha256=A5z2ss1-zq6_UHavs6mBgxsllXLz5hYbKCNRAjD-ONw,3152
26
25
  artemis_model/schedule.py,sha256=CkLHWz-BwvUY2EQCfoU4SymgCariPzoQdtRLITqBPmk,2451
27
26
  artemis_model/setting.py,sha256=xe5SHDziY8RzFxzB1GzousxI1FXYhyXZ5proEseS60g,1190
@@ -31,6 +30,7 @@ artemis_model/track.py,sha256=QwUF0QKVn1I64648B-NI75-IzGQvnLt9B0emD4GnS6E,3757
31
30
  artemis_model/user.py,sha256=eqIdCiBJRNLjCwPPCn-gQ6si0O5JUBGfp9oWJL5zVW4,2131
32
31
  artemis_model/zone.py,sha256=iGRUtzUwKh9LHT3MOfzzg1DnkPBts_ZBzZVTi2EmIgs,2282
33
32
  artemis_model/zone_activity.py,sha256=BY4iODavY9ceJ5oRChdjjxf26S3U30Yb7Pxm5YRFpCo,1590
34
- artemis_model-0.1.163.dist-info/METADATA,sha256=NEHYvHPgrd3ZAe-R5e8mF55sO5gmTP_MtZwz8f7vGMk,3496
35
- artemis_model-0.1.163.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
36
- artemis_model-0.1.163.dist-info/RECORD,,
33
+ artemis_model/zone_state.py,sha256=kjDJ4FwIg6SYsLyjKbkQMq9Wex6fPcmBMObeQ17ugRE,2703
34
+ artemis_model-0.1.166.dist-info/METADATA,sha256=8IW1cudevYvbRWAWX327aHUJ6DPkBnQbVj_8YsFZdlk,3496
35
+ artemis_model-0.1.166.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
36
+ artemis_model-0.1.166.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- """User related data models and helpers."""
2
-
3
- import hashlib
4
-
5
-
6
- def hash_token(token: str) -> str:
7
- """Hash the given token."""
8
- return hashlib.sha256(token.encode()).hexdigest()