Skip to content

Commit

Permalink
Add support for relational lookups on ObjectsByDateTracker
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrospdc committed Feb 3, 2017
1 parent 1b528b1 commit c647bd4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion trackstats/trackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.db import models
from django.db import connections
from django.utils import timezone
from functools import reduce

from .models import Period, StatisticByDate, StatisticByDateAndObject

Expand All @@ -20,6 +21,9 @@ def __init__(self, **kwargs):
for prop, val in kwargs.items():
setattr(self, prop, val)

def _get_start_date(self, obj, start_date):
return

def get_most_recent_kwargs(self):
most_recent_kwargs = {
'metric': self.metric,
Expand All @@ -37,7 +41,7 @@ def get_start_date(self, qs):
if first_instance is None:
# No data
return
start_date = getattr(first_instance, self.date_field)
start_date = reduce(getattr, self.date_field.split('__'), first_instance)
if start_date and isinstance(start_date, datetime):
if timezone.is_aware(start_date):
start_date = timezone.make_naive(start_date).date()
Expand Down

0 comments on commit c647bd4

Please sign in to comment.