Skip to content

Commit

Permalink
global leaderboard, subjecttype
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Sander committed Jul 28, 2017
1 parent 504740f commit 3944f48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions gengine/app/leaderboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
class GlobalLeaderBoardSubjectSet:

@classmethod
def forward(cls, from_date, to_date, whole_time_required):
q = select([t_subjects.c.id, ])
def forward(cls, subjecttype_id, from_date, to_date, whole_time_required):
q = select([t_subjects.c.id, ]).where(t_subjects.c.subjecttype_id == subjecttype_id)
if whole_time_required:
q = q.where(and_(
t_subjects.c.created_at <= from_date,
t_subjects.c.created_at <= from_date
#or_(
# t_subjects.c.deleted_at == None,
# t_subjects.c.deleted_at >= to_date
Expand Down Expand Up @@ -91,13 +91,13 @@ def forward(cls, subject_id, from_date, to_date, whole_time_required):
class ContextSubjectLeaderBoardSubjectSet:

@classmethod
def forward(cls, subject_type_id, context_subject_id, from_date, to_date, whole_time_required=False):
def forward(cls, subjecttype_id, context_subject_id, from_date, to_date, whole_time_required=False):
# We are comparing all subjects of type subject_type which have been part of context_subject_id between from_date and to_date
# By default, they don't have to be member all the time (whole_time_required).

ancestor_subjects = Subject.get_descendent_subjects(
subject_id=context_subject_id,
of_type_id=subject_type_id,
of_type_id=subjecttype_id,
from_date=from_date,
to_date=to_date,
whole_time_required=whole_time_required
Expand Down
3 changes: 2 additions & 1 deletion gengine/app/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,13 +1323,14 @@ def get_relevant_subjects_by_achievement_and_subject(cls, achievement, subject,
subjects = set(subjects) | {subject.id}
elif achievement["comparison_type"] == "global":
subjects = GlobalLeaderBoardSubjectSet.forward(
subjecttype_id=subject["subjecttype_id"],
from_date=from_date,
to_date=to_date,
whole_time_required=achievement["lb_subject_part_whole_time"]
)
elif achievement["comparison_type"] == "context_subject":
subjects = ContextSubjectLeaderBoardSubjectSet.forward(
subject_type_id=subject["subjecttype_id"],
subjecttype_id=subject["subjecttype_id"],
context_subject_id=context_subject_id,
from_date=from_date,
to_date=to_date,
Expand Down

0 comments on commit 3944f48

Please sign in to comment.