forked from openlp/openlp
Add debugging to help with seach results
bzr-revno: 268
This commit is contained in:
parent
b3fb6aa182
commit
c9c3317483
@ -201,6 +201,7 @@ class SongDBImpl(BibleCommon):
|
|||||||
metadata.bind.echo = False
|
metadata.bind.echo = False
|
||||||
searchtext = "%"+searchtext+"%"
|
searchtext = "%"+searchtext+"%"
|
||||||
s = text (""" SELECT s.songid AS songid, s.songtitle AS songtitle, a.authorname AS authorname FROM songs s OUTER JOIN songauthors sa ON s.songid = sa.songid OUTER JOIN authors a ON sa.authorid = a.authorid WHERE s.lyrics LIKE :t ORDER BY s.songtitle ASC """)
|
s = text (""" SELECT s.songid AS songid, s.songtitle AS songtitle, a.authorname AS authorname FROM songs s OUTER JOIN songauthors sa ON s.songid = sa.songid OUTER JOIN authors a ON sa.authorid = a.authorid WHERE s.lyrics LIKE :t ORDER BY s.songtitle ASC """)
|
||||||
|
log.debug("Records returned from search %s", len(self.db.execute(s, t=searchtext).fetchall()))
|
||||||
return self.db.execute(s, t=searchtext).fetchall()
|
return self.db.execute(s, t=searchtext).fetchall()
|
||||||
|
|
||||||
def get_song_from_title(self,searchtext):
|
def get_song_from_title(self,searchtext):
|
||||||
@ -208,6 +209,7 @@ class SongDBImpl(BibleCommon):
|
|||||||
metadata.bind.echo = False
|
metadata.bind.echo = False
|
||||||
searchtext = "%"+searchtext+"%"
|
searchtext = "%"+searchtext+"%"
|
||||||
s = text (""" SELECT s.songid AS songid, s.songtitle AS songtitle, a.authorname AS authorname FROM songs s OUTER JOIN songauthors sa ON s.songid = sa.songid OUTER JOIN authors a ON sa.authorid = a.authorid WHERE s.songtitle LIKE :t ORDER BY s.songtitle ASC """)
|
s = text (""" SELECT s.songid AS songid, s.songtitle AS songtitle, a.authorname AS authorname FROM songs s OUTER JOIN songauthors sa ON s.songid = sa.songid OUTER JOIN authors a ON sa.authorid = a.authorid WHERE s.songtitle LIKE :t ORDER BY s.songtitle ASC """)
|
||||||
|
log.debug("Records returned from search %s", len(self.db.execute(s, t=searchtext).fetchall()))
|
||||||
return self.db.execute(s, t=searchtext).fetchall()
|
return self.db.execute(s, t=searchtext).fetchall()
|
||||||
|
|
||||||
def get_song_from_author(self,searchtext):
|
def get_song_from_author(self,searchtext):
|
||||||
@ -215,6 +217,7 @@ class SongDBImpl(BibleCommon):
|
|||||||
metadata.bind.echo = False
|
metadata.bind.echo = False
|
||||||
searchtext = "%"+searchtext+"%"
|
searchtext = "%"+searchtext+"%"
|
||||||
s = text (""" SELECT s.songid AS songid, s.songtitle AS songtitle, a.authorname AS authorname FROM songs s OUTER JOIN songauthors sa ON s.songid = sa.songid OUTER JOIN authors a ON sa.authorid = a.authorid WHERE a.authorname LIKE :t ORDER BY s.songtitle ASC """)
|
s = text (""" SELECT s.songid AS songid, s.songtitle AS songtitle, a.authorname AS authorname FROM songs s OUTER JOIN songauthors sa ON s.songid = sa.songid OUTER JOIN authors a ON sa.authorid = a.authorid WHERE a.authorname LIKE :t ORDER BY s.songtitle ASC """)
|
||||||
|
log.debug("Records returned from search %s", len(self.db.execute(s, t=searchtext).fetchall()))
|
||||||
return self.db.execute(s, t=searchtext).fetchall()
|
return self.db.execute(s, t=searchtext).fetchall()
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class SongManager():
|
|||||||
log.debug( "Song Initialising")
|
log.debug( "Song Initialising")
|
||||||
self.authorcache = None
|
self.authorcache = None
|
||||||
self.songPath = self.config.get_data_path()
|
self.songPath = self.config.get_data_path()
|
||||||
self.songSuffix = self.config.get_config("suffix name", u'olp3')
|
self.songSuffix = self.config.get_config("suffix name", u'olp3,sqlite')
|
||||||
log.debug("Song Path %s and suffix %s", self.songPath, self.songSuffix )
|
log.debug("Song Path %s and suffix %s", self.songPath, self.songSuffix )
|
||||||
self.dialogobject = None
|
self.dialogobject = None
|
||||||
|
|
||||||
@ -218,12 +218,15 @@ class SongManager():
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def get_song_from_title(self,searchtext):
|
def get_song_from_title(self,searchtext):
|
||||||
|
log.debug("get song from title %s", searchtext)
|
||||||
return self.songDBCache.get_song_from_title(searchtext)
|
return self.songDBCache.get_song_from_title(searchtext)
|
||||||
|
|
||||||
def get_song_from_lyrics(self,searchtext):
|
def get_song_from_lyrics(self,searchtext):
|
||||||
|
log.debug("get song from lyrics %s", searchtext)
|
||||||
return self.songDBCache.get_song_from_lyrics(searchtext)
|
return self.songDBCache.get_song_from_lyrics(searchtext)
|
||||||
|
|
||||||
def get_song_from_author(self,searchtext):
|
def get_song_from_author(self,searchtext):
|
||||||
|
log.debug("get song from author %s", searchtext)
|
||||||
return self.songDBCache.get_song_from_author(searchtext)
|
return self.songDBCache.get_song_from_author(searchtext)
|
||||||
|
|
||||||
def dump_songs(self):
|
def dump_songs(self):
|
||||||
|
@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License along with
|
|||||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
"""
|
"""
|
||||||
|
import logging
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
@ -27,6 +28,9 @@ from forms import EditSongForm, OpenLPImportForm, OpenSongImportForm, \
|
|||||||
from openlp.plugins.songs.lib import SongManager
|
from openlp.plugins.songs.lib import SongManager
|
||||||
|
|
||||||
class SongsPlugin(Plugin, PluginUtils):
|
class SongsPlugin(Plugin, PluginUtils):
|
||||||
|
global log
|
||||||
|
log=logging.getLogger("SongsPlugin")
|
||||||
|
log.info("Song Plugin loaded")
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Call the parent constructor
|
# Call the parent constructor
|
||||||
Plugin.__init__(self, 'Songs', '1.9.0')
|
Plugin.__init__(self, 'Songs', '1.9.0')
|
||||||
@ -208,10 +212,13 @@ class SongsPlugin(Plugin, PluginUtils):
|
|||||||
searchtext = str(self.SearchTextEdit.displayText() )
|
searchtext = str(self.SearchTextEdit.displayText() )
|
||||||
ct = self.SearchTypeComboBox.currentText()
|
ct = self.SearchTypeComboBox.currentText()
|
||||||
if self.SearchTypeComboBox.currentText()=="Titles":
|
if self.SearchTypeComboBox.currentText()=="Titles":
|
||||||
|
log.debug("Titles Search")
|
||||||
self.searchresults = self.songmanager.get_song_from_title(searchtext)
|
self.searchresults = self.songmanager.get_song_from_title(searchtext)
|
||||||
elif self.SearchTypeComboBox.currentText()=="Lyrics":
|
elif self.SearchTypeComboBox.currentText()=="Lyrics":
|
||||||
|
log.debug("Lyrics Search")
|
||||||
self.searchresults = self.songmanager.get_song_from_lyrics(searchtext)
|
self.searchresults = self.songmanager.get_song_from_lyrics(searchtext)
|
||||||
elif self.SearchTypeComboBox.currentText()=="Authors":
|
elif self.SearchTypeComboBox.currentText()=="Authors":
|
||||||
|
log.debug("Authors Search")
|
||||||
self.searchresults = self.songmanager.get_song_from_author(searchtext)
|
self.searchresults = self.songmanager.get_song_from_author(searchtext)
|
||||||
|
|
||||||
self._display_results()
|
self._display_results()
|
||||||
@ -253,10 +260,12 @@ class SongsPlugin(Plugin, PluginUtils):
|
|||||||
self.opensong_export_form.show()
|
self.opensong_export_form.show()
|
||||||
|
|
||||||
def _display_results(self):
|
def _display_results(self):
|
||||||
|
log.debug("_search results")
|
||||||
self.SongListView.clear() # clear the results
|
self.SongListView.clear() # clear the results
|
||||||
self.SongListView.setHorizontalHeaderLabels(QtCore.QStringList(["","Song Name","Author"]))
|
self.SongListView.setHorizontalHeaderLabels(QtCore.QStringList(["","Song Name","Author"]))
|
||||||
self.SongListView.setVerticalHeaderLabels(QtCore.QStringList([""]))
|
self.SongListView.setVerticalHeaderLabels(QtCore.QStringList([""]))
|
||||||
self.SongListView.setRowCount(0)
|
self.SongListView.setRowCount(0)
|
||||||
|
log.debug("Records returned from search %s", len(self.searchresults))
|
||||||
for id, txt, name in self.searchresults:
|
for id, txt, name in self.searchresults:
|
||||||
c = self.SongListView.rowCount()
|
c = self.SongListView.rowCount()
|
||||||
self.SongListView.setRowCount(c+1)
|
self.SongListView.setRowCount(c+1)
|
||||||
|
Loading…
Reference in New Issue
Block a user