Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add simple success rate calculation #5104

Merged
merged 2 commits into from
Sep 4, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2365,6 +2365,17 @@ def is_staff(self):
"""
return self.user.is_staff if self.user else False

@property
def success_rate(self):
network = self.get_network()
num_completed_bounties = self.bounties.filter(
idx_status__in=['done'], network=network).count()
terminal_state_bounties = self.bounties.filter(
idx_status__in=Bounty.TERMINAL_STATUSES, network=network).count()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't know how to solve the cooperative bounty case, since I can be paid out but the bounty still open.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is kind of the same situation on the dashboard, should we fetch fulfillments also?

if terminal_state_bounties == 0:
return 1.0
return num_completed_bounties * 1.0 / (terminal_state_bounties + num_completed_bounties)

@property
def get_quarterly_stats(self):
"""Generate last 90 days stats for this user.
Expand Down