3 if(doc.doc_type == "EpisodeUserState")
5 if(doc.actions.length < 1)
10 var action = doc.actions[doc.actions.length-1];
13 podcast_url: doc.podcast_ref_url,
14 episode_url: doc.ref_url,
15 podcast_id: doc.podcast,
16 episode_id: doc.episode,
17 action: action.action,
18 timestamp: action.timestamp.slice(0, action.timestamp.length-1),
21 if(action.device != null)
23 action_obj["device_id"] = action.device;
25 if(action.started != null)
27 action_obj["started"] = action.started;
29 if(action.playmark != null)
31 action_obj["position"] = action.playmark;
33 if(action.total != null)
35 action_obj["total"] = action.total;
39 emit([doc.user, doc.podcast, doc.episode], action_obj);