[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Librefm-commits] [1151] reduce some duplication
From: |
Clint Adams |
Subject: |
[Librefm-commits] [1151] reduce some duplication |
Date: |
Sun, 03 May 2009 14:22:31 +0000 |
Revision: 1151
http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1151
Author: clint
Date: 2009-05-03 14:22:29 +0000 (Sun, 03 May 2009)
Log Message:
-----------
reduce some duplication
Modified Paths:
--------------
trunk/scripts/setstids
Modified: trunk/scripts/setstids
===================================================================
--- trunk/scripts/setstids 2009-05-03 13:55:44 UTC (rev 1150)
+++ trunk/scripts/setstids 2009-05-03 14:22:29 UTC (rev 1151)
@@ -11,7 +11,7 @@
def doit(self):
- self.cursor = self.conn.Execute('SELECT * from Scrobbles WHERE
stid is NULL');
+ self.cursor = self.conn.Execute('SELECT DISTINCT artist, album,
track, mbid from Scrobbles WHERE stid is NULL');
while not self.cursor.EOF:
row = self.cursor.GetRowAssoc(0)
@@ -19,8 +19,6 @@
album = row['album']
track = row['track']
mbid = row['mbid']
- username = row['username']
- time = row['time']
stid = self.lookupStid(artist,album,track,mbid)
if not stid:
tid = self.lookupTrack(artist, album, track,
mbid)
@@ -32,7 +30,7 @@
self.acursor =
self.conn.Execute("INSERT INTO Track (artist,album,name,mbid)
VALUES(%(artist)s,%(album)s,%(name)s,%(mbid)s)", {'artist': artist, 'album':
album, 'name': track, 'mbid': mbid})
else:
print "Setting %d to match %s/%s/%s/%s" %
(stid,artist,album,track,mbid)
- self.scursor = self.conn.Execute("UPDATE
Scrobbles SET stid = %(stid)s WHERE username = %(username)s AND track =
%(track)s AND artist = %(artist)s AND time = %(time)s AND stid IS NULL",
{'stid': stid, 'username': username, 'track': track, 'artist': artist, 'time':
time})
+ self.scursor = self.conn.Execute("UPDATE
Scrobbles SET stid = %%(stid)s WHERE track = %%(track)s AND artist =
%%(artist)s AND %s AND %s AND stid IS NULL" % (('lower(album) =
lower(%(album)s)' if album else 'album IS NULL'), ('lower(mbid) =
lower(%(mbid)s)' if mbid else 'mbid IS NULL')), {'stid': stid, 'track': track,
'artist': artist, 'album': album, 'mbid': mbid})
self.cursor.MoveNext()
def lookupStid(self, artist, album, track, mbid):
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Librefm-commits] [1151] reduce some duplication,
Clint Adams <=