add filter generic/is_types
[mygpo.git] / couchdb / general / _design / episode_states / views / by_user_podcast / map.js
blob4d45107452bdef9cff1d373971293a24f321829d
1 function(doc)
3     if(doc.doc_type == "EpisodeUserState")
4     {
5         if(doc.actions.length < 1)
6         {
7             return;
8         }
10         var action = doc.actions[doc.actions.length-1];
12         var action_obj = {
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),
19             }
21         if(action.device != null)
22         {
23             action_obj["device_id"] = action.device;
24         }
25         if(action.started != null)
26         {
27             action_obj["started"] = action.started;
28         }
29         if(action.playmark != null)
30         {
31             action_obj["position"] = action.playmark;
32         }
33         if(action.total != null)
34         {
35             action_obj["total"] = action.total;
36         }
39         emit([doc.user, doc.podcast, doc.episode], action_obj);
40     }