add filter generic/is_types
[mygpo.git] / couchdb / general / _design / episode_actions / views / by_podcast / map.js
blob65c12a17a3eba54788bdbd8851e1049416826951
1 function(doc)
3     if(doc.doc_type == "EpisodeUserState")
4     {
5         for(var n in doc.actions)
6         {
7             var action = doc.actions[n];
9             var action_obj = {
10                     podcast:   doc.podcast_ref_url,
11                     episode:   doc.ref_url,
12                     action:    action.action,
13                     timestamp: action.timestamp.slice(0, action.timestamp.length-1),
14                 }
16             if(action.device != null)
17             {
18                 action_obj["device_id"] = action.device;
19             }
20             if(action.started != null)
21             {
22                 action_obj["started"] = action.started;
23             }
24             if(action.playmark != null)
25             {
26                 action_obj["position"] = action.playmark;
27             }
28             if(action.total != null)
29             {
30                 action_obj["total"] = action.total;
31             }
33             emit([
34                     doc.user,
35                     doc.podcast,
36                     action.upload_timestamp
37                 ], action_obj
38             );
39         }
40     }