3 function processEpisodeAction(action)
7 podcast_url: doc.podcast_ref_url,
8 episode_url: doc.ref_url,
9 podcast_id: doc.podcast,
10 episode_id: doc.episode,
11 action: action.action,
12 timestamp: action.timestamp.slice(0, action.timestamp.length-1),
15 if(action.device != null)
17 action_obj["device_id"] = action.device;
19 if(action.started != null)
21 action_obj["started"] = action.started;
23 if(action.playmark != null)
25 action_obj["position"] = action.playmark;
27 if(action.total != null)
29 action_obj["total"] = action.total;
32 emit([doc.user, action_obj.timestamp], action_obj);
35 function processSubscriptionAction(action)
39 podcast_url: doc.ref_url,
40 podcast_id: doc.podcast,
41 action: action.action,
42 timestamp: action.timestamp.slice(0, action.timestamp.length-1),
43 device_id: action.device,
46 emit([doc.user, action_obj.timestamp], action_obj);
50 if(doc.doc_type == "EpisodeUserState")
52 for(var n in doc.actions)
54 processEpisodeAction(doc.actions[n]);
57 if(doc.doc_type == "PodcastUserState")
59 for(var n in doc.actions)
61 processSubscriptionAction(doc.actions[n]);