+ action = orm.Action(\r
+ user_id=uidmap[sxv['userid']],\r
+ action_date = readTime(sxv['creationdate']),\r
+ )\r
+\r
+ node = posts.get(int(sxv['postid']), None)\r
+ if not node: continue\r
+ action.node = node\r
+\r
+ if sxv['votetypeid'] == '1':\r
+ answer = node\r
+ question = posts.get(int(answer.parent_id), None)\r
+\r
+ action.action_type = "acceptanswer"\r
+ action.save()\r
+\r
+ answer.marked = True\r
+ answer.extra_action = action\r
+\r
+ question.extra_ref_id = answer.id\r
+\r
+ answer.save()\r
+ question.save()\r
+\r
+ elif sxv['votetypeid'] in ('2', '3'):\r
+ if not (action.node.id, action.user_id) in user2vote:\r
+ user2vote.append((action.node.id, action.user_id))\r
+\r
+ action.action_type = (sxv['votetypeid'] == '2') and "voteup" or "votedown"\r
+ action.save()\r
+\r
+ ov = orm.Vote(\r
+ node_id = action.node.id,\r
+ user_id = action.user_id,\r
+ voted_at = action.action_date,\r
+ value = sxv['votetypeid'] == '2' and 1 or -1,\r
+ action = action\r
+ )\r
+ ov.save()\r
+ else:\r
+ action.action_type = "unknown"\r
+ action.save()\r
+\r
+ elif sxv['votetypeid'] in ('4', '12', '13'):\r
+ action.action_type = "flag"\r
+ action.save()\r
+\r
+ of = orm.Flag(\r
+ node = action.node,\r
+ user_id = action.user_id,\r
+ flagged_at = action.action_date,\r
+ reason = '',\r
+ action = action\r
+ )\r
+\r
+ of.save()\r
+\r
+ elif sxv['votetypeid'] == '5':\r
+ action.action_type = "favorite"\r
+ action.save()\r
+\r
+ elif sxv['votetypeid'] == '6':\r
+ action.action_type = "close"\r
+ action.extra = dbsafe_encode(close_reasons[sxv['comment']])\r
+ action.save()\r
+\r
+ node.marked = True\r
+ node.extra_action = action\r
+ node.save()\r
+\r
+ elif sxv['votetypeid'] == '7':\r
+ action.action_type = "unknown"\r
+ action.save()\r
+ \r
+ node.marked = False\r
+ node.extra_action = None\r
+ node.save()\r
+\r
+ elif sxv['votetypeid'] == '10':\r
+ action.action_type = "delete"\r
+ action.save()\r
+\r
+ node.deleted = action\r
+ node.save()\r
+\r
+ elif sxv['votetypeid'] == '11':\r
+ action.action_type = "unknown"\r
+ action.save()\r
+\r
+ node.deleted = None\r
+ node.save()\r
+\r
+ else:\r
+ action.action_type = "unknown"\r
+ action.save()\r
+\r
+\r
+ if sxv.get('targetrepchange', None):\r
+ rep = orm.ActionRepute(\r
+ action = action,\r
+ date = action.action_date,\r
+ user_id = uidmap[sxv['targetuserid']],\r
+ value = int(sxv['targetrepchange'])\r
+ )\r
+\r
+ rep.save()\r
+\r
+ if sxv.get('voterrepchange', None):\r
+ rep = orm.ActionRepute(\r
+ action = action,\r
+ date = action.action_date,\r