diff options
Diffstat (limited to 'lib/dtas/mlib.rb')
-rw-r--r-- | lib/dtas/mlib.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/dtas/mlib.rb b/lib/dtas/mlib.rb index 34c0c82..c7ea1df 100644 --- a/lib/dtas/mlib.rb +++ b/lib/dtas/mlib.rb @@ -341,7 +341,6 @@ class DTAS::Mlib # success load_tags - require 'yaml' @tag_rmap = @tag_map.invert if found[:tlen] == DM_DIR emit_recurse(found) @@ -353,6 +352,27 @@ class DTAS::Mlib end end + def count_distinct(tag) + s = 'SELECT COUNT(DISTINCT(val_id)) FROM comments WHERE tag_id = ?' + @db.fetch(s, @tag_map[tag]).single_value + end + + def count_songs + @db.fetch('SELECT COUNT(*) FROM nodes WHERE tlen >= 0').single_value + end + + def db_playtime + @db.fetch('SELECT SUM(tlen) FROM nodes WHERE tlen >= 0').single_value + end + + def stats + %w(artist album).each do |k| + puts "#{k}s: #{count_distinct(k)}" + end + puts "songs: #{count_songs}" + puts "db_playtime: #{db_playtime}" + end + def path_of(node) return '/' if node[:name] == '' parts = [ node[:name], '' ] |