Exemple #1
0
def get_stopstalk_user_stats():
    if request.extension != "json":
        raise HTTP(400)
        return

    user_id = request.vars.get("user_id", None)
    custom = request.vars.get("custom", None)

    final_data = dict(rating_history=[],
                      curr_accepted_streak=0,
                      max_accepted_streak=0,
                      curr_day_streak=0,
                      max_day_streak=0,
                      solved_counts={},
                      status_percentages=[],
                      site_accuracies={},
                      solved_problems_count=0,
                      total_problems_count=0,
                      calendar_data={})

    if user_id in [None, ""] or custom in [None, ""]:
        return final_data

    user_id = int(user_id)
    custom = (custom == "True")

    result = utilities.get_rating_information(user_id, custom,
                                              auth.is_logged_in())
    return result
Exemple #2
0
 def should_show(self):
     cache_value = self.get_from_cache()
     if cache_value:
         self.stats = cache_value
     else:
         self.stats = utilities.get_rating_information(
             self.user_id, False, True)
         self.set_to_cache(self.stats)
     return self.key_name in self.stats and \
            self.stats[self.key_name] > 0
field_names = [
    "StopStalk handle", "Total solved", "Total problems", "StopStalk Rating"
]

for site in current.SITES:
    field_names.append(site + " Accuracy")
    field_names.append(site + " Solved")

field_names.append("Maximum day streak")

stats_table.field_names = field_names
rows = [field_names]

for user in users:
    result = utilities.get_rating_information(user.id, False, False)
    print "Added result for user:"******"solved_problems_count"],
        result["total_problems_count"], user.stopstalk_rating
    ]
    for site in current.SITES:
        if site in result["site_accuracies"]:
            row.append(result["site_accuracies"][site])
        else:
            row.append("-")
        if site in result["solved_counts"]:
            row.append(result["solved_counts"][site])
        else:
            row.append(0)
    row.append(result["max_day_streak"])