- orm.Vote(user_id=action.user_id, node_id=action.node_id, action=action,
- voted_at=action.action_date, value=(action.action_type != 'votedown') and 1 or -1).save()
+ # Check to see if the vote has already been registered.
+ if not (action.user_id, action.node_id) in persisted_votes:
+ # Persist the vote action.
+ orm.Vote(user_id=action.user_id, node_id=action.node_id, action=action,
+ voted_at=action.action_date, value=(action.action_type != 'votedown') and 1 or -1).save()
+
+ # Record the vote action. This will help us avoid duplicates.
+ persisted_votes.append((action.user_id, action.node_id))
+