artemis-model 0.1.94__tar.gz → 0.1.96__tar.gz

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.
Files changed (30) hide show
  1. {artemis_model-0.1.94 → artemis_model-0.1.96}/PKG-INFO +1 -1
  2. artemis_model-0.1.96/artemis_model/redis/__init__.py +26 -0
  3. artemis_model-0.1.96/artemis_model/redis/bucket.py +47 -0
  4. artemis_model-0.1.96/artemis_model/redis/keys.py +16 -0
  5. {artemis_model-0.1.94 → artemis_model-0.1.96}/pyproject.toml +1 -1
  6. artemis_model-0.1.94/artemis_model/redis/__init__.py +0 -6
  7. {artemis_model-0.1.94 → artemis_model-0.1.96}/README.md +0 -0
  8. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/__init__.py +0 -0
  9. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/album.py +0 -0
  10. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/artist.py +0 -0
  11. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/auth.py +0 -0
  12. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/base.py +0 -0
  13. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/category.py +0 -0
  14. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/dj_set.py +0 -0
  15. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/genre.py +0 -0
  16. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/location.py +0 -0
  17. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/message.py +0 -0
  18. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/organization.py +0 -0
  19. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/otp.py +0 -0
  20. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/permission.py +0 -0
  21. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/playlist.py +0 -0
  22. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/redis/device.py +0 -0
  23. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/redis/zone_state.py +0 -0
  24. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/schedule.py +0 -0
  25. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/setting.py +0 -0
  26. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/sqs/__init__.py +0 -0
  27. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/sqs/messages.py +0 -0
  28. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/track.py +0 -0
  29. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/user.py +0 -0
  30. {artemis_model-0.1.94 → artemis_model-0.1.96}/artemis_model/zone.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: artemis-model
3
- Version: 0.1.94
3
+ Version: 0.1.96
4
4
  Summary:
5
5
  Author: Jukeboxy
6
6
  Requires-Python: >=3.10.6,<4.0.0
@@ -0,0 +1,26 @@
1
+ """Redis models."""
2
+
3
+ from .zone_state import ZoneState, NowPlaying, SessionId, BucketId
4
+ from .device import ActiveDevice
5
+ from .bucket import RedisTrackBucketItem
6
+ from .keys import (
7
+ KEY_ZONE_PLAY_HISTORY_TEMPLATE,
8
+ KEY_ZONE_PUSH_PLAYLIST_BUCKET_TEMPLATE,
9
+ KEY_ZONE_SCHEDULE_BUCKET_TEMPLATE,
10
+ KEY_ZONE_STATE_TEMPLATE,
11
+ KEY_ZONE_ACTIVE_DEVICE_TEMPLATE,
12
+ )
13
+
14
+ __all__ = [
15
+ "ZoneState",
16
+ "NowPlaying",
17
+ "SessionId",
18
+ "BucketId",
19
+ "ActiveDevice",
20
+ "KEY_ZONE_PLAY_HISTORY_TEMPLATE",
21
+ "KEY_ZONE_PUSH_PLAYLIST_BUCKET_TEMPLATE",
22
+ "KEY_ZONE_SCHEDULE_BUCKET_TEMPLATE",
23
+ "KEY_ZONE_STATE_TEMPLATE",
24
+ "KEY_ZONE_ACTIVE_DEVICE_TEMPLATE",
25
+ "RedisTrackBucketItem",
26
+ ]
@@ -0,0 +1,47 @@
1
+ """Redis track buckets"""
2
+ from pydantic import BaseModel, Field, ConfigDict
3
+ from typing import Annotated
4
+ from datetime import datetime, timezone
5
+ import uuid
6
+
7
+
8
+ TrackId = Annotated[
9
+ uuid.UUID,
10
+ Field(description="Track ID (UUID)")
11
+ ]
12
+
13
+ PlaylistId = Annotated[
14
+ int,
15
+ Field(description="Playlist ID (integer)")
16
+ ]
17
+
18
+ Timestamp = Annotated[
19
+ int,
20
+ Field(description="Unix timestamp")
21
+ ]
22
+
23
+
24
+ class RedisTrackBucketItem(BaseModel):
25
+ """
26
+ Represents a composite Redis key along with a timestamp.
27
+ The Redis entry will be:
28
+ { '{"track_id": "...", "playlist_id": ...}': ts }
29
+ ts is the timestamp of utc now.
30
+ """
31
+
32
+ track_id: TrackId
33
+ playlist_id: PlaylistId
34
+ ts: Timestamp = Field(default_factory=lambda: int(datetime.now(timezone.utc).timestamp()))
35
+
36
+ model_config = ConfigDict(
37
+ json_encoders={uuid.UUID: str},
38
+ populate_by_name=True
39
+ )
40
+
41
+ def as_redis_entry(self) -> dict[str, int]:
42
+ """
43
+ Generate a Redis-ready dictionary:
44
+ { '{"track_id": "...", "playlist_id": ...}': ts }
45
+ """
46
+ key = self.model_dump_json(include={"track_id", "playlist_id"})
47
+ return {key: self.ts}
@@ -0,0 +1,16 @@
1
+ """Redis keys."""
2
+
3
+ KEY_ZONE_PLAY_HISTORY_TEMPLATE = "zone_{zone_id}_play_history"
4
+ KEY_ZONE_PUSH_PLAYLIST_BUCKET_TEMPLATE = "zone_{zone_id}_pp_bucket_{timeslot_ts}"
5
+ KEY_ZONE_SCHEDULE_BUCKET_TEMPLATE = "zone_{zone_id}_sc_bucket_{timeslot_ts}"
6
+ KEY_ZONE_STATE_TEMPLATE = "zone_{zone_id}_state"
7
+ KEY_ZONE_ACTIVE_DEVICE_TEMPLATE = "zone_{zone_id}_active_devices"
8
+
9
+
10
+ __all__ = [
11
+ "KEY_ZONE_PLAY_HISTORY_TEMPLATE",
12
+ "KEY_ZONE_PUSH_PLAYLIST_BUCKET_TEMPLATE",
13
+ "KEY_ZONE_SCHEDULE_BUCKET_TEMPLATE",
14
+ "KEY_ZONE_STATE_TEMPLATE",
15
+ "KEY_ZONE_ACTIVE_DEVICE_TEMPLATE",
16
+ ]
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "artemis-model"
3
- version = "0.1.94"
3
+ version = "0.1.96"
4
4
  description = ""
5
5
  authors = ["Jukeboxy"]
6
6
  readme = "README.md"
@@ -1,6 +0,0 @@
1
- """Redis models."""
2
-
3
- from .zone_state import ZoneState, NowPlaying, SessionId, BucketId
4
- from .device import ActiveDevice
5
-
6
- __all__ = ["ZoneState", "NowPlaying", "SessionId", "BucketId", "ActiveDevice"]
File without changes