add filter generic/is_types
[mygpo.git] / couchdb / general / _design / subscribers / views / by_podcast / map.js
blob84e969edcbd55b415db7f29598b1e2b2c03e40ba
1 function(doc)
3     if(doc.doc_type == "PodcastUserState")
4     {
5         var subscribed_devices = [];
7         for(var n in doc.actions)
8         {
9             var action = doc.actions[n];
11             if(action.action == "subscribe")
12             {
13                 subscribed_devices.push(action.device);
14             }
15             else if(action.action == "unsubscribe")
16             {
17                 var index = subscribed_devices.indexOf(action.device);
18                 subscribed_devices.splice(index, 1);
19             }
20         }
22         if (subscribed_devices.length > 0)
23         {
24             emit([doc.podcast, doc.user], null);
25         }
26     }