move categories into own database
[mygpo.git] / couchdb / general / _design / tags / views / by_podcast / map.js
blob3ee479f8c437786e755784b0a3e3ec6780d40b64
1 function(doc)
3     function searchPodcast(podcast, podcast_id)
4     {
5         for(var source in podcast.tags)
6         {
7             for(var n in podcast.tags[source])
8             {
9                 emit([podcast_id, podcast.tags[source][n]], sourceWeight(source));
10             }
11         }
12     }
14     function sourceWeight(source)
15     {
16         if(source == "feed")
17         {
18             return 1;
19         }
20         else if (source == "delicious")
21         {
22             return 2;
23         }
24         else
25         {
26             return 0;
27         }
28     }
30     if(doc.doc_type == "Podcast")
31     {
32         searchPodcast(doc, doc._id);
33     }
34     else if(doc.doc_type == "PodcastGroup")
35     {
36         for(var p in doc.podcasts)
37         {
38             searchPodcast(p, p.id);
39         }
40     }