Skip to content

Commit 0169594

Browse files
authored
Fix timestamp defaulting bug (#58)
* Fix timestamp defaulting bug * Lint * Bump version
1 parent a25c742 commit 0169594

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

analytics/analytics.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ def __init__(
4545
self,
4646
product: Product,
4747
pennkey: Optional[str],
48-
timestamp=timezone.now(),
49-
data=list(),
48+
timestamp=None,
49+
data=None,
5050
):
5151
self.product = product.value
5252
self.pennkey = pennkey
53-
self.timestamp = timestamp.timestamp()
54-
self.data = data
53+
self.timestamp = (timestamp or timezone.now()).timestamp()
54+
self.data = data or []
5555

5656
def to_json(self):
5757
return json.loads(json.dumps(vars(self)))
@@ -70,9 +70,10 @@ def submit(
7070
data: List[dict],
7171
product: Optional[Product] = None,
7272
pennkey: Optional[str] = None,
73-
timestamp=timezone.now(),
73+
timestamp=None,
7474
):
7575
product = product if product is not None else self.default_product
76+
timestamp = timestamp or timezone.now()
7677
txn = AnalyticsTxn(product or self.default_product, pennkey, timestamp, data)
7778
self.submit_transaction(txn)
7879

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django-labs-accounts"
3-
version = "1.0.4"
3+
version = "1.0.5"
44
description = "Reusable Django app for Penn Labs accounts"
55
authors = ["Penn Labs <contact@pennlabs.org>"]
66
license = "MIT"

0 commit comments

Comments
 (0)