From c580474557e506fd8da803b0a2bfab1b42b8217d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20K=C3=B6gl?= Date: Sat, 13 Apr 2013 14:23:58 +0200 Subject: [PATCH] add CouchDB view for file-type stats --- .../_design/episode_stats/views/filetypes/map.js | 23 ++++++++++++++++++++++ .../episode_stats/views/filetypes/reduce.js | 1 + 2 files changed, 24 insertions(+) create mode 100644 couchdb/_design/episode_stats/views/filetypes/map.js create mode 100644 couchdb/_design/episode_stats/views/filetypes/reduce.js diff --git a/couchdb/_design/episode_stats/views/filetypes/map.js b/couchdb/_design/episode_stats/views/filetypes/map.js new file mode 100644 index 00000000..fa9a6d51 --- /dev/null +++ b/couchdb/_design/episode_stats/views/filetypes/map.js @@ -0,0 +1,23 @@ +function(doc) +{ + if(doc.doc_type == "Episode") + { + for(var n in doc.urls) + { + var url = doc.urls[n]; + var i = url.lastIndexOf("."); + + if(i >= 0) + { + /* exclude the dot */ + var ext = url.substr(i+1); + + /* make sure we exclude obvious non-extensions */ + if (ext.length < 10) + { + emit(ext, url); + } + } + } + } +} diff --git a/couchdb/_design/episode_stats/views/filetypes/reduce.js b/couchdb/_design/episode_stats/views/filetypes/reduce.js new file mode 100644 index 00000000..c866cd72 --- /dev/null +++ b/couchdb/_design/episode_stats/views/filetypes/reduce.js @@ -0,0 +1 @@ +_count -- 2.11.4.GIT