Skip to content

Commit

Permalink
remove usrs w/ incomplete quests from word cloud
Browse files Browse the repository at this point in the history
also, repair scaling in cloud.min.js: [d3.select("input[name=scale]:checked").property("value")]().range([20, 50]),  Based on known issue: jasondavies/d3-cloud#36
  • Loading branch information
JTFouquier committed May 5, 2016
1 parent d1176ed commit 27f01f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions mark2cure/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,24 @@ def doc_count(self):

def top_five_contributors(self):
"""returns a user name list for the group"""
uqr = UserQuestRelationship.objects.filter(task__group=self)
uqrs = UserQuestRelationship.objects.filter(task__group=self)
username_list = []
for user in uqr:
# (TODO) not sure if this is the fastest approach
username_list.append(str.encode(str(user.user.username)))
for uqr in uqrs:
if uqr.completed:
# (TODO) not sure if this is the fastest approach
username_list.append(str.encode(str(uqr.user.username)))
counter = Counter(username_list)
top_five_users = [tuple_i[0] for tuple_i in counter.most_common(5)]
return top_five_users, username_list

def total_contributors(self):
"""returns a user name list for the group"""
uqr = UserQuestRelationship.objects.filter(task__group=self)
uqrs = UserQuestRelationship.objects.filter(task__group=self)
username_list = []
for user in uqr:
# (TODO) not sure if this is the best approach:
username_list.append(str.encode(str(user.user.username)))
for uqr in uqrs:
if uqr.completed:
# (TODO) not sure if this is the best approach:
username_list.append(str.encode(str(uqr.user.username)))
total_contributors = len(set(username_list))
return total_contributors

Expand Down
2 changes: 1 addition & 1 deletion static/js/tasks/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function parseText(t) {
}

function generate() {
layout.font(d3.select("#font").property("value")).spiral(d3.select("input[name=spiral]:checked").property("value")), fontSize = d3.scale[d3.select("input[name=scale]:checked").property("value")]().range([30, 80]), tags.length && fontSize.domain([+tags[tags.length - 1].value || 1, +tags[0].value]), complete = 0, statusText.style("display", null), words = [], layout.stop().words(tags.slice(0, max = Math.min(tags.length, +d3.select("#max").property("value")))).start()
layout.font(d3.select("#font").property("value")).spiral(d3.select("input[name=spiral]:checked").property("value")), fontSize = d3.scale[d3.select("input[name=scale]:checked").property("value")]().range([20, 50]), tags.length && fontSize.domain([+tags[tags.length - 1].value || 1, +tags[0].value]), complete = 0, statusText.style("display", null), words = [], layout.stop().words(tags.slice(0, max = Math.min(tags.length, +d3.select("#max").property("value")))).start()
}

function progress(t) {
Expand Down

0 comments on commit 27f01f8

Please sign in to comment.