def callback(sxa): badge = sx_to_osqa[int(sxa['badgeid'])] user_id = uidmap[sxa['userid']] if not user_badge_count.get(user_id, None): user_badge_count[user_id] = 0 action = orm.Action( action_type = "award", user_id = user_id, action_date = readTime(sxa['date']) ) action.save() osqaa = orm.Award( user_id = uidmap[sxa['userid']], badge = badge, node_id = post_list[user_badge_count[user_id]], awarded_at = action.action_date, action = action ) osqaa.save() badge.awarded_count += 1 user_badge_count[user_id] += 1
def awards_import(row, badges, nodes, users, actions): badge_type = badges.get(row.getc('badge'), None) if not badge_type: return action = row.get('action').as_int(None) trigger = row.get('trigger').as_int(None) node = row.get('node').as_int(None) user = row.get('user').as_int() if orm.Award.objects.filter(badge=badges[row.getc('badge')], user=users.get(user, user), node=nodes.get(node, node)).count(): return award = orm.Award(user_id=users.get(user, user), badge=badge_type, node_id=nodes.get(node, node), action_id=actions.get(action, action), trigger_id=actions.get(trigger, trigger)).save()