def contributions(self, request): res = {} for date_, contribution in UserContributions.get_by_user(self.name).iteritems(): timestamp = time.mktime(datetime.strptime(date_, "%Y-%m-%d").timetuple()) score = contribution[0] res.setdefault(timestamp, score) return res
def contributions(self, request): res = {} for date_, contribution in UserContributions.get_by_user( self.name).iteritems(): timestamp = time.mktime( datetime.strptime(date_, '%Y-%m-%d').timetuple()) score = contribution[0] res.setdefault(timestamp, score) return res
def contributions(self, request): res = {} days = int(request.get_form_var('days', 31)) for date_, contribution in UserContributions.get_by_user( self.user.name, days=days).iteritems(): timestamp = time.mktime( datetime.strptime(date_, '%Y-%m-%d').timetuple()) score = contribution[0] res.setdefault(timestamp, score) return res
def contribution_detail(self, request): req_date = request.get_form_var("date") if req_date: try: req_date = dateutil.parser.parse(req_date).astimezone(dateutil.tz.tzoffset("EST", 8 * 3600)) except ValueError as e: return "" contributions = UserContributions.get_by_date(self.name, req_date) owned = contributions.get("owned_tickets") commented = contributions.get("commented_tickets") owned_tickets = filter(None, [Ticket.get(id_) for id_ in owned]) commented_tickets = filter(None, [Ticket.get(comment[0]) for comment in commented]) return st("people_contribution_detail.html", **locals()) return ""
def contribution_detail(self, request): req_date = request.get_form_var('date') if req_date: try: req_date = dateutil.parser.parse(req_date).astimezone( dateutil.tz.tzoffset('EST', 8 * 3600)) except ValueError as e: return "" contributions = UserContributions.get_by_date(self.name, req_date) owned = contributions.get('owned_tickets') commented = contributions.get('commented_tickets') owned_tickets = filter(None, [Ticket.get(id_) for id_ in owned]) commented_tickets = filter( None, [Ticket.get(comment[0]) for comment in commented]) return st('people_contribution_detail.html', **locals()) return ""
def contribution_detail(self, request): req_date = request.get_form_var('date') if not req_date: return {"error": "No datetime"} try: req_date = dateutil.parser.parse(req_date).astimezone( dateutil.tz.tzoffset('EST', 8 * 3600)) except ValueError: return {"error": "Invalid date"} contributions = UserContributions.get_by_date(self.user.name, req_date) owned = contributions.get('owned_tickets') commented = contributions.get('commented_tickets') pullreqs = [Ticket.get(id_).as_dict() for id_ in owned] participated = [ Ticket.get(comment[0]).as_dict() for comment in commented ] return {"pull requests": pullreqs, "participated": participated}
def contribution_detail(self, request): req_date = request.get_form_var('date') if not req_date: return {"error": "No datetime"} try: req_date = dateutil.parser.parse(req_date).astimezone( dateutil.tz.tzoffset('EST', 8 * 3600)) except ValueError: return {"error": "Invalid date"} contributions = UserContributions.get_by_date(self.user.name, req_date) owned = contributions.get('owned_tickets') commented = contributions.get('commented_tickets') pullreqs = [Ticket.get(id_).as_dict() for id_ in owned] participated = [Ticket.get(comment[0]).as_dict() for comment in commented] return {"pull requests": pullreqs, "participated": participated}
def update_user_contributions(): from vilya.models.contributions import UserContributions users = get_users() for user in users: UserContributions.update_by_user(user.name)