bitmapist 3.115__tar.gz → 3.116__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.
- {bitmapist-3.115 → bitmapist-3.116}/PKG-INFO +5 -6
- {bitmapist-3.115 → bitmapist-3.116}/README.md +3 -3
- {bitmapist-3.115 → bitmapist-3.116}/bitmapist/__init__.py +56 -35
- {bitmapist-3.115 → bitmapist-3.116}/bitmapist/cohort/__init__.py +3 -3
- {bitmapist-3.115 → bitmapist-3.116}/pyproject.toml +1 -1
- {bitmapist-3.115 → bitmapist-3.116}/AUTHORS +0 -0
- {bitmapist-3.115 → bitmapist-3.116}/bitmapist/cohort/tmpl/form_data.mako +0 -0
- {bitmapist-3.115 → bitmapist-3.116}/bitmapist/cohort/tmpl/table_data.mako +0 -0
- {bitmapist-3.115 → bitmapist-3.116}/bitmapist/cohort/tmpl/table_data_csv.mako +0 -0
- {bitmapist-3.115 → bitmapist-3.116}/bitmapist/py.typed +0 -0
- {bitmapist-3.115 → bitmapist-3.116}/static/bitmapist.png +0 -0
- {bitmapist-3.115 → bitmapist-3.116}/static/bitmapist.svg +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: bitmapist
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.116
|
|
4
4
|
Summary: Implements a powerful analytics library using Redis bitmaps.
|
|
5
|
-
Home-page: https://github.com/Doist/bitmapist
|
|
6
5
|
License: BSD
|
|
7
6
|
Keywords: redis,bitmap,analytics,bitmaps,realtime,cohort
|
|
8
7
|
Author: Amir Salihefendic
|
|
@@ -83,13 +82,13 @@ Can be installed very easily via:
|
|
|
83
82
|
Setting things up:
|
|
84
83
|
|
|
85
84
|
```python
|
|
86
|
-
from datetime import datetime, timedelta
|
|
85
|
+
from datetime import datetime, timedelta, timezone
|
|
87
86
|
from bitmapist import setup_redis, delete_all_events, mark_event,\
|
|
88
87
|
MonthEvents, WeekEvents, DayEvents, HourEvents,\
|
|
89
88
|
BitOpAnd, BitOpOr
|
|
90
89
|
|
|
91
|
-
now = datetime.
|
|
92
|
-
last_month =
|
|
90
|
+
now = datetime.now(tz=timezone.utc)
|
|
91
|
+
last_month = now - timedelta(days=30)
|
|
93
92
|
```
|
|
94
93
|
|
|
95
94
|
Mark user 123 as active and has played a song:
|
|
@@ -54,13 +54,13 @@ Can be installed very easily via:
|
|
|
54
54
|
Setting things up:
|
|
55
55
|
|
|
56
56
|
```python
|
|
57
|
-
from datetime import datetime, timedelta
|
|
57
|
+
from datetime import datetime, timedelta, timezone
|
|
58
58
|
from bitmapist import setup_redis, delete_all_events, mark_event,\
|
|
59
59
|
MonthEvents, WeekEvents, DayEvents, HourEvents,\
|
|
60
60
|
BitOpAnd, BitOpOr
|
|
61
61
|
|
|
62
|
-
now = datetime.
|
|
63
|
-
last_month =
|
|
62
|
+
now = datetime.now(tz=timezone.utc)
|
|
63
|
+
last_month = now - timedelta(days=30)
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
Mark user 123 as active and has played a song:
|
|
@@ -33,8 +33,8 @@ Setting things up::
|
|
|
33
33
|
from datetime import datetime, timedelta
|
|
34
34
|
from bitmapist import mark_event, MonthEvents
|
|
35
35
|
|
|
36
|
-
now = datetime.
|
|
37
|
-
last_month =
|
|
36
|
+
now = datetime.now(tz=timezone.utc)
|
|
37
|
+
last_month = now - timedelta(days=30)
|
|
38
38
|
|
|
39
39
|
Mark user 123 as active::
|
|
40
40
|
|
|
@@ -84,7 +84,7 @@ from __future__ import annotations
|
|
|
84
84
|
import calendar
|
|
85
85
|
import threading
|
|
86
86
|
from collections import defaultdict
|
|
87
|
-
from datetime import date, datetime, timedelta
|
|
87
|
+
from datetime import date, datetime, timedelta, timezone
|
|
88
88
|
from typing import TYPE_CHECKING, Any, Optional, Union
|
|
89
89
|
|
|
90
90
|
import redis
|
|
@@ -159,7 +159,7 @@ def mark_event(
|
|
|
159
159
|
:param :system The Redis system to use (string, Redis instance, or Pipeline
|
|
160
160
|
instance).
|
|
161
161
|
:param :now Which date should be used as a reference point, default is
|
|
162
|
-
`datetime.
|
|
162
|
+
`datetime.now(tz=timezone.utc)`
|
|
163
163
|
:param :track_hourly Should hourly stats be tracked, defaults to
|
|
164
164
|
bitmapist.TRACK_HOURLY
|
|
165
165
|
:param :track_unique Should unique stats be tracked, defaults to
|
|
@@ -200,7 +200,7 @@ def _mark(
|
|
|
200
200
|
event_name,
|
|
201
201
|
uuid: int,
|
|
202
202
|
system="default",
|
|
203
|
-
now=None,
|
|
203
|
+
now: Optional[datetime] = None,
|
|
204
204
|
track_hourly=None,
|
|
205
205
|
track_unique=None,
|
|
206
206
|
use_pipeline: bool = True,
|
|
@@ -210,9 +210,8 @@ def _mark(
|
|
|
210
210
|
track_hourly = TRACK_HOURLY
|
|
211
211
|
if track_unique is None:
|
|
212
212
|
track_unique = TRACK_UNIQUE
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
now = datetime.utcnow()
|
|
213
|
+
if now is None:
|
|
214
|
+
now = datetime.now(tz=timezone.utc)
|
|
216
215
|
|
|
217
216
|
obj_classes: list[
|
|
218
217
|
type[MonthEvents]
|
|
@@ -474,12 +473,14 @@ class YearEvents(GenericPeriodEvents):
|
|
|
474
473
|
"""
|
|
475
474
|
|
|
476
475
|
@classmethod
|
|
477
|
-
def from_date(
|
|
478
|
-
|
|
476
|
+
def from_date(
|
|
477
|
+
cls, event_name, dt: Optional[date | datetime] = None, system="default"
|
|
478
|
+
):
|
|
479
|
+
dt = dt or datetime.now(tz=timezone.utc)
|
|
479
480
|
return cls(event_name, dt.year, system=system)
|
|
480
481
|
|
|
481
482
|
def __init__(self, event_name, year=None, system="default"):
|
|
482
|
-
now = datetime.
|
|
483
|
+
now = datetime.now(tz=timezone.utc)
|
|
483
484
|
self.event_name = event_name
|
|
484
485
|
self.year = not_none(year, now.year)
|
|
485
486
|
self.system = system
|
|
@@ -492,10 +493,10 @@ class YearEvents(GenericPeriodEvents):
|
|
|
492
493
|
return self.__class__(self.event_name, self.year + value, self.system)
|
|
493
494
|
|
|
494
495
|
def period_start(self):
|
|
495
|
-
return datetime(self.year, 1, 1)
|
|
496
|
+
return datetime(self.year, 1, 1, tzinfo=timezone.utc)
|
|
496
497
|
|
|
497
498
|
def period_end(self):
|
|
498
|
-
return datetime(self.year, 12, 31, 23, 59, 59, 999999)
|
|
499
|
+
return datetime(self.year, 12, 31, 23, 59, 59, 999999, tzinfo=timezone.utc)
|
|
499
500
|
|
|
500
501
|
|
|
501
502
|
class MonthEvents(GenericPeriodEvents):
|
|
@@ -508,12 +509,14 @@ class MonthEvents(GenericPeriodEvents):
|
|
|
508
509
|
"""
|
|
509
510
|
|
|
510
511
|
@classmethod
|
|
511
|
-
def from_date(
|
|
512
|
-
|
|
512
|
+
def from_date(
|
|
513
|
+
cls, event_name, dt: Optional[date | datetime] = None, system="default"
|
|
514
|
+
):
|
|
515
|
+
dt = dt or datetime.now(tz=timezone.utc)
|
|
513
516
|
return cls(event_name, dt.year, dt.month, system=system)
|
|
514
517
|
|
|
515
518
|
def __init__(self, event_name, year=None, month=None, system="default"):
|
|
516
|
-
now = datetime.
|
|
519
|
+
now = datetime.now(tz=timezone.utc)
|
|
517
520
|
self.event_name = event_name
|
|
518
521
|
self.year = not_none(year, now.year)
|
|
519
522
|
self.month = not_none(month, now.month)
|
|
@@ -525,11 +528,13 @@ class MonthEvents(GenericPeriodEvents):
|
|
|
525
528
|
return self.__class__(self.event_name, year, month, self.system)
|
|
526
529
|
|
|
527
530
|
def period_start(self):
|
|
528
|
-
return datetime(self.year, self.month, 1)
|
|
531
|
+
return datetime(self.year, self.month, 1, tzinfo=timezone.utc)
|
|
529
532
|
|
|
530
533
|
def period_end(self):
|
|
531
534
|
_, day = calendar.monthrange(self.year, self.month)
|
|
532
|
-
return datetime(
|
|
535
|
+
return datetime(
|
|
536
|
+
self.year, self.month, day, 23, 59, 59, 999999, tzinfo=timezone.utc
|
|
537
|
+
)
|
|
533
538
|
|
|
534
539
|
|
|
535
540
|
class WeekEvents(GenericPeriodEvents):
|
|
@@ -543,14 +548,17 @@ class WeekEvents(GenericPeriodEvents):
|
|
|
543
548
|
|
|
544
549
|
@classmethod
|
|
545
550
|
def from_date(
|
|
546
|
-
cls,
|
|
551
|
+
cls,
|
|
552
|
+
event_name: str,
|
|
553
|
+
dt: Optional[date | datetime] = None,
|
|
554
|
+
system: str = "default",
|
|
547
555
|
):
|
|
548
|
-
dt = dt or datetime.
|
|
556
|
+
dt = dt or datetime.now(tz=timezone.utc)
|
|
549
557
|
dt_year, dt_week, _ = dt.isocalendar()
|
|
550
558
|
return cls(event_name, dt_year, dt_week, system=system)
|
|
551
559
|
|
|
552
560
|
def __init__(self, event_name: str, year=None, week=None, system="default"):
|
|
553
|
-
now = datetime.
|
|
561
|
+
now = datetime.now(tz=timezone.utc)
|
|
554
562
|
now_year, now_week, _ = now.isocalendar()
|
|
555
563
|
self.event_name = event_name
|
|
556
564
|
self.year = not_none(year, now_year)
|
|
@@ -565,11 +573,11 @@ class WeekEvents(GenericPeriodEvents):
|
|
|
565
573
|
|
|
566
574
|
def period_start(self):
|
|
567
575
|
s = iso_to_gregorian(self.year, self.week, 1) # mon
|
|
568
|
-
return datetime(s.year, s.month, s.day)
|
|
576
|
+
return datetime(s.year, s.month, s.day, tzinfo=timezone.utc)
|
|
569
577
|
|
|
570
578
|
def period_end(self):
|
|
571
579
|
e = iso_to_gregorian(self.year, self.week, 7) # mon
|
|
572
|
-
return datetime(e.year, e.month, e.day, 23, 59, 59, 999999)
|
|
580
|
+
return datetime(e.year, e.month, e.day, 23, 59, 59, 999999, tzinfo=timezone.utc)
|
|
573
581
|
|
|
574
582
|
|
|
575
583
|
class DayEvents(GenericPeriodEvents):
|
|
@@ -582,12 +590,14 @@ class DayEvents(GenericPeriodEvents):
|
|
|
582
590
|
"""
|
|
583
591
|
|
|
584
592
|
@classmethod
|
|
585
|
-
def from_date(
|
|
586
|
-
|
|
593
|
+
def from_date(
|
|
594
|
+
cls, event_name: str, dt: Optional[date | datetime] = None, system="default"
|
|
595
|
+
):
|
|
596
|
+
dt = dt or datetime.now(tz=timezone.utc)
|
|
587
597
|
return cls(event_name, dt.year, dt.month, dt.day, system=system)
|
|
588
598
|
|
|
589
599
|
def __init__(self, event_name, year=None, month=None, day=None, system="default"):
|
|
590
|
-
now = datetime.
|
|
600
|
+
now = datetime.now(tz=timezone.utc)
|
|
591
601
|
self.event_name = event_name
|
|
592
602
|
self.year = not_none(year, now.year)
|
|
593
603
|
self.month = not_none(month, now.month)
|
|
@@ -600,10 +610,12 @@ class DayEvents(GenericPeriodEvents):
|
|
|
600
610
|
return self.__class__(self.event_name, dt.year, dt.month, dt.day, self.system)
|
|
601
611
|
|
|
602
612
|
def period_start(self) -> datetime:
|
|
603
|
-
return datetime(self.year, self.month, self.day)
|
|
613
|
+
return datetime(self.year, self.month, self.day, tzinfo=timezone.utc)
|
|
604
614
|
|
|
605
615
|
def period_end(self) -> datetime:
|
|
606
|
-
return datetime(
|
|
616
|
+
return datetime(
|
|
617
|
+
self.year, self.month, self.day, 23, 59, 59, 999999, tzinfo=timezone.utc
|
|
618
|
+
)
|
|
607
619
|
|
|
608
620
|
|
|
609
621
|
class HourEvents(GenericPeriodEvents):
|
|
@@ -619,7 +631,7 @@ class HourEvents(GenericPeriodEvents):
|
|
|
619
631
|
def from_date(
|
|
620
632
|
cls, event_name: str, dt: Optional[datetime] = None, system="default"
|
|
621
633
|
):
|
|
622
|
-
dt = dt or datetime.
|
|
634
|
+
dt = dt or datetime.now(tz=timezone.utc)
|
|
623
635
|
return cls(event_name, dt.year, dt.month, dt.day, dt.hour, system=system)
|
|
624
636
|
|
|
625
637
|
def __init__(
|
|
@@ -631,7 +643,7 @@ class HourEvents(GenericPeriodEvents):
|
|
|
631
643
|
hour: Optional[int] = None,
|
|
632
644
|
system: str = "default",
|
|
633
645
|
):
|
|
634
|
-
now = datetime.
|
|
646
|
+
now = datetime.now(tz=timezone.utc)
|
|
635
647
|
self.event_name = event_name
|
|
636
648
|
self.year = not_none(year, now.year)
|
|
637
649
|
self.month = not_none(month, now.month)
|
|
@@ -643,18 +655,27 @@ class HourEvents(GenericPeriodEvents):
|
|
|
643
655
|
)
|
|
644
656
|
|
|
645
657
|
def delta(self, value):
|
|
646
|
-
dt = datetime(
|
|
647
|
-
|
|
648
|
-
)
|
|
658
|
+
dt = datetime(
|
|
659
|
+
self.year, self.month, self.day, self.hour, tzinfo=timezone.utc
|
|
660
|
+
) + timedelta(hours=value)
|
|
649
661
|
return self.__class__(
|
|
650
662
|
self.event_name, dt.year, dt.month, dt.day, dt.hour, self.system
|
|
651
663
|
)
|
|
652
664
|
|
|
653
665
|
def period_start(self) -> datetime:
|
|
654
|
-
return datetime(self.year, self.month, self.day, self.hour)
|
|
666
|
+
return datetime(self.year, self.month, self.day, self.hour, tzinfo=timezone.utc)
|
|
655
667
|
|
|
656
668
|
def period_end(self) -> datetime:
|
|
657
|
-
return datetime(
|
|
669
|
+
return datetime(
|
|
670
|
+
self.year,
|
|
671
|
+
self.month,
|
|
672
|
+
self.day,
|
|
673
|
+
self.hour,
|
|
674
|
+
59,
|
|
675
|
+
59,
|
|
676
|
+
999999,
|
|
677
|
+
tzinfo=timezone.utc,
|
|
678
|
+
)
|
|
658
679
|
|
|
659
680
|
|
|
660
681
|
# --- Bit operations
|
|
@@ -62,7 +62,7 @@ Get the data and render it via HTML::
|
|
|
62
62
|
:license: BSD
|
|
63
63
|
"""
|
|
64
64
|
|
|
65
|
-
from datetime import date, datetime, timedelta
|
|
65
|
+
from datetime import date, datetime, timedelta, timezone
|
|
66
66
|
from os import path
|
|
67
67
|
from typing import Any, Callable, Literal, Optional, Union
|
|
68
68
|
|
|
@@ -228,10 +228,10 @@ def get_dates_data(
|
|
|
228
228
|
num_of_rows = int(num_of_rows)
|
|
229
229
|
|
|
230
230
|
if start_date:
|
|
231
|
-
now = datetime.strptime(start_date, "%Y-%m-%d")
|
|
231
|
+
now = datetime.strptime(start_date, "%Y-%m-%d").replace(tzinfo=timezone.utc)
|
|
232
232
|
now = now + timedelta(days=num_results - 1)
|
|
233
233
|
else:
|
|
234
|
-
now = datetime.
|
|
234
|
+
now = datetime.now(tz=timezone.utc)
|
|
235
235
|
|
|
236
236
|
# Days
|
|
237
237
|
if time_group == "days":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|