3 function processEpisodeAction(action)
5 if(action.device == null)
12 podcast_url: doc.podcast_ref_url,
13 episode_url: doc.ref_url,
14 podcast_id: doc.podcast,
15 episode_id: doc.episode,
16 action: action.action,
17 timestamp: action.timestamp.slice(0, action.timestamp.length-1),
20 if(action.device != null)
22 action_obj["device_id"] = action.device;
24 if(action.started != null)
26 action_obj["started"] = action.started;
28 if(action.playmark != null)
30 action_obj["position"] = action.playmark;
32 if(action.total != null)
34 action_obj["total"] = action.total;
37 emit([doc.user, action.device, action_obj.timestamp], action_obj);
40 function processSubscriptionAction(action)
44 podcast_url: doc.ref_url,
45 podcast_id: doc.podcast,
46 action: action.action,
47 timestamp: action.timestamp.slice(0, action.timestamp.length-1),
48 device_id: action.device,
51 emit([doc.user, action.device, action_obj.timestamp], action_obj);
55 if(doc.doc_type == "EpisodeUserState")
57 for(var n in doc.actions)
59 processEpisodeAction(doc.actions[n]);
62 if(doc.doc_type == "PodcastUserState")
64 for(var n in doc.actions)
66 processSubscriptionAction(doc.actions[n]);