Loading opds_catalog/__pycache__/feeds.cpython-35.pyc +16 B (38.8 KiB) File changed.No diff preview for this file type. View original file View changed file opds_catalog/__pycache__/settings.cpython-35.pyc +183 B (2.78 KiB) File changed.No diff preview for this file type. View original file View changed file opds_catalog/feeds.py +8 −8 Original line number Diff line number Diff line Loading @@ -528,9 +528,9 @@ class SearchAuthorsFeed(AuthFeed): page = int(page) if searchtype == 'm': authors = Author.objects.extra(where=["upper(last_name) like %s"], params=["%%%s%%"%searchterms.upper().strip()]) authors = Author.objects.extra(where=["upper(concat(last_name,' ',first_name)) like %s"], params=["%%%s%%"%searchterms.upper()]) elif searchtype == 'b': authors = Author.objects.extra(where=["upper(last_name) like %s"], params=["%s%%"%searchterms.upper().strip()]) authors = Author.objects.extra(where=["upper(concat(last_name,' ',first_name)) like %s"], params=["%s%%"%searchterms.upper()]) return {"authors":authors, "searchterms":searchterms, "searchtype":searchtype, "page":page} def link(self, obj): Loading Loading @@ -788,16 +788,16 @@ class AuthorsFeed(AuthFeed): def items(self, obj): length, chars = obj if self.lang_code: sql="""select upper(substring(last_name || ' ' || first_name,1,%(length)s)) as id, count(*) as cnt sql="""select upper(substring(concat(last_name,' ',first_name),1,%(length)s)) as id, count(*) as cnt from opds_catalog_author where lang_code=%(lang_code)s and upper(last_name || ' ' || first_name) like '%(chars)s%%' group by upper(substring(last_name || ' ' || first_name,1,%(length)s)) where lang_code=%(lang_code)s and upper(concat(last_name,' ',first_name)) like '%(chars)s%%' group by upper(substring(concat(last_name,' ',first_name),1,%(length)s)) order by id"""%{'length':length, 'lang_code':self.lang_code, 'chars':chars} else: sql="""select upper(substring(last_name || ' ' || first_name,1,%(length)s)) as id, count(*) as cnt sql="""select upper(substring(concat(last_name,' ',first_name),1,%(length)s)) as id, count(*) as cnt from opds_catalog_author where upper(last_name || ' ' || first_name) like '%(chars)s%%' group by upper(substring(last_name || ' ' || first_name,1,%(length)s)) where upper(concat(last_name,' ',first_name)) like '%(chars)s%%' group by upper(substring(concat(last_name,' ',first_name),1,%(length)s)) order by id"""%{'length':length,'chars':chars} dataset = Author.objects.raw(sql) Loading opds_catalog/settings.py +4 −0 Original line number Diff line number Diff line Loading @@ -52,8 +52,12 @@ def sopds_substring(s,i,l): i = i - 1 return s[i:i+l] def sopds_concat(s1='',s2='',s3=''): return "%s%s%s"%(s1,s2,s3) @receiver(connection_created) def extend_sqlite(connection=None, **kwargs): if connection.vendor == "sqlite": connection.connection.create_function('upper',1,sopds_upper) connection.connection.create_function('substring',3,sopds_substring) connection.connection.create_function('concat',3,sopds_concat) Loading
opds_catalog/__pycache__/feeds.cpython-35.pyc +16 B (38.8 KiB) File changed.No diff preview for this file type. View original file View changed file
opds_catalog/__pycache__/settings.cpython-35.pyc +183 B (2.78 KiB) File changed.No diff preview for this file type. View original file View changed file
opds_catalog/feeds.py +8 −8 Original line number Diff line number Diff line Loading @@ -528,9 +528,9 @@ class SearchAuthorsFeed(AuthFeed): page = int(page) if searchtype == 'm': authors = Author.objects.extra(where=["upper(last_name) like %s"], params=["%%%s%%"%searchterms.upper().strip()]) authors = Author.objects.extra(where=["upper(concat(last_name,' ',first_name)) like %s"], params=["%%%s%%"%searchterms.upper()]) elif searchtype == 'b': authors = Author.objects.extra(where=["upper(last_name) like %s"], params=["%s%%"%searchterms.upper().strip()]) authors = Author.objects.extra(where=["upper(concat(last_name,' ',first_name)) like %s"], params=["%s%%"%searchterms.upper()]) return {"authors":authors, "searchterms":searchterms, "searchtype":searchtype, "page":page} def link(self, obj): Loading Loading @@ -788,16 +788,16 @@ class AuthorsFeed(AuthFeed): def items(self, obj): length, chars = obj if self.lang_code: sql="""select upper(substring(last_name || ' ' || first_name,1,%(length)s)) as id, count(*) as cnt sql="""select upper(substring(concat(last_name,' ',first_name),1,%(length)s)) as id, count(*) as cnt from opds_catalog_author where lang_code=%(lang_code)s and upper(last_name || ' ' || first_name) like '%(chars)s%%' group by upper(substring(last_name || ' ' || first_name,1,%(length)s)) where lang_code=%(lang_code)s and upper(concat(last_name,' ',first_name)) like '%(chars)s%%' group by upper(substring(concat(last_name,' ',first_name),1,%(length)s)) order by id"""%{'length':length, 'lang_code':self.lang_code, 'chars':chars} else: sql="""select upper(substring(last_name || ' ' || first_name,1,%(length)s)) as id, count(*) as cnt sql="""select upper(substring(concat(last_name,' ',first_name),1,%(length)s)) as id, count(*) as cnt from opds_catalog_author where upper(last_name || ' ' || first_name) like '%(chars)s%%' group by upper(substring(last_name || ' ' || first_name,1,%(length)s)) where upper(concat(last_name,' ',first_name)) like '%(chars)s%%' group by upper(substring(concat(last_name,' ',first_name),1,%(length)s)) order by id"""%{'length':length,'chars':chars} dataset = Author.objects.raw(sql) Loading
opds_catalog/settings.py +4 −0 Original line number Diff line number Diff line Loading @@ -52,8 +52,12 @@ def sopds_substring(s,i,l): i = i - 1 return s[i:i+l] def sopds_concat(s1='',s2='',s3=''): return "%s%s%s"%(s1,s2,s3) @receiver(connection_created) def extend_sqlite(connection=None, **kwargs): if connection.vendor == "sqlite": connection.connection.create_function('upper',1,sopds_upper) connection.connection.create_function('substring',3,sopds_substring) connection.connection.create_function('concat',3,sopds_concat)