move remaining view files
[mygpo.git] / couchdb / _design / podcasts / views / by_tag / map.js
blob45098e4872699309f48ef2a3f93d6154aa7685df
1 function(doc)
3     function searchPodcast(podcast, podcast_id)
4     {
5         for(source in podcast.tags)
6         {
7             for(n in podcast.tags[source])
8             {
9                 emit([podcast.tags[source][n], podcast_id], 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(p in doc.podcasts)
37         {
38             searchPodcast(p, p.id);
39         }
40     }