File indexing completed on 2024-05-05 04:49:36

0001 #!/usr/bin/env ruby
0002 #
0003 # Ruby script to remove stale statistics in the database
0004 # (c) 2005 Seb Ruiz <me@sebruiz.net>
0005 # License: GNU General Public License V2
0006 
0007 system("dcop", "amarok", "playlist", "shortStatusMessage", "Removing stale entries from the database")
0008 
0009 qresult = `dcop amarok collection query "SELECT url FROM statistics;"`
0010 result = qresult.split( "\n" )
0011 
0012 i = 0
0013 
0014 result.each do |url|
0015     unless FileTest.exist?( url )
0016         i = i + 1
0017         url.gsub!(/[']/, '\\\\\'')
0018         puts "Deleting: #{url}"
0019         system("dcop", "amarok", "collection", "query", "DELETE FROM statistics WHERE url = '#{url}'")
0020     end
0021 end
0022 
0023 if i > 0
0024     system("dcop", "amarok", "playlist", "popupMessage", "Removed #{i} stale entries from the database")
0025 end