Skip to content

Commit

Permalink
Fix assignment comparison count issue
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-gardener committed Jul 18, 2017
1 parent af6bea9 commit 22004c8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions compair/models/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def criteria(self):

@hybrid_property
def compared(self):
return self.compare_count > 0
return self.all_compare_count > 0

def completed_comparison_count_for_user(self, user_id):
comparison_count = self.comparisons \
Expand Down Expand Up @@ -254,13 +254,23 @@ def __declare_last__(cls):
group="counts"
)

cls.compare_count = column_property(
cls.all_compare_count = column_property(
select([func.count(Comparison.id)]).
where(Comparison.assignment_id == cls.id),
deferred=True,
group="counts"
)

cls.compare_count = column_property(
select([func.count(Comparison.id)]).
where(and_(
Comparison.assignment_id == cls.id,
Comparison.completed == True
)),
deferred=True,
group="counts"
)

cls.self_evaluation_count = column_property(
select([func.count(AnswerComment.id)]).
where(and_(
Expand Down

0 comments on commit 22004c8

Please sign in to comment.