Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
55bdd13f
Commit
55bdd13f
authored
Apr 14, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #877
parent
4552208c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
8 deletions
+24
-8
web.py
cps/web.py
+24
-8
No files found.
cps/web.py
View file @
55bdd13f
...
...
@@ -78,6 +78,7 @@ import server
from reverseproxy import ReverseProxied
from updater import updater_thread
import hashlib
import unidecode
try:
from googleapiclient.errors import HttpError
...
...
@@ -665,16 +666,23 @@ def get_search_results(term):
q = list()
authorterms = re.split("[, ]+", term)
for authorterm in authorterms:
q
.
append
(
db
.
Books
.
authors
.
any
(
db
.
Authors
.
name
.
ilike
(
"
%
"
+
authorterm
+
"
%
"
)))
q.append(db.Books.authors.any(db.or_(db.Authors.name.ilike("%" + authorterm + "%"),
db.Authors.name.ilike("%" + unidecode.unidecode(authorterm) + "%"))))
db.session.connection().connection.connection.create_function("lower", 1, db.lcase)
db
.
Books
.
authors
.
any
(
db
.
Authors
.
name
.
ilike
(
"
%
"
+
term
+
"
%
"
))
db.Books.authors.any(db.or_(db.Authors.name.ilike("%" + term + "%"),
db.Authors.name.ilike("%" + unidecode.unidecode(term) + "%")))
return db.session.query(db.Books).filter(common_filters()).filter(
db.or_(db.Books.tags.any(db.Tags.name.ilike("%" + term + "%")),
db.Books.series.any(db.Series.name.ilike("%" + term + "%")),
db.Books.authors.any(and_(*q)),
db.Books.publishers.any(db.Publishers.name.ilike("%" + term + "%")),
db
.
Books
.
title
.
ilike
(
"
%
"
+
term
+
"
%
"
)))
.
all
()
db.Books.title.ilike("%" + term + "%"),
db.Books.tags.any(db.Tags.name.ilike("%" + unidecode.unidecode(term) + "%")),
db.Books.series.any(db.Series.name.ilike("%" + unidecode.unidecode(term) + "%")),
db.Books.publishers.any(db.Publishers.name.ilike("%" + unidecode.unidecode(term) + "%")),
db.Books.title.ilike("%" + unidecode.unidecode(term) + "%")
)).all()
def feed_search(term):
...
...
@@ -1969,15 +1977,20 @@ def advanced_search():
searchterm = " + ".join(filter(None, searchterm))
q = q.filter()
if author_name:
q
=
q
.
filter
(
db
.
Books
.
authors
.
any
(
db
.
Authors
.
name
.
ilike
(
"
%
"
+
author_name
+
"
%
"
)))
q = q.filter(db.Books.authors.any(db.or_(db.Authors.name.ilike("%" + author_name + "%"),
db.Authors.name.ilike("%" + unidecode.unidecode(author_name)
+ "%"))))
if book_title:
q
=
q
.
filter
(
db
.
Books
.
title
.
ilike
(
"
%
"
+
book_title
+
"
%
"
))
q = q.filter(db.or_(db.Books.title.ilike("%" + book_title + "%"),
db.Books.title.ilike("%" + unidecode.unidecode(book_title) + "%")))
if pub_start:
q = q.filter(db.Books.pubdate >= pub_start)
if pub_end:
q = q.filter(db.Books.pubdate <= pub_end)
if publisher:
q
=
q
.
filter
(
db
.
Books
.
publishers
.
any
(
db
.
Publishers
.
name
.
ilike
(
"
%
"
+
publisher
+
"
%
"
)))
q = q.filter(db.Books.publishers.any(db.or_(db.Publishers.name.ilike("%" + publisher + "%"),
db.Publishers.name.ilike("%" + unidecode.unidecode(publisher)
+ "%"),)))
for tag in include_tag_inputs:
q = q.filter(db.Books.tags.any(db.Tags.id == tag))
for tag in exclude_tag_inputs:
...
...
@@ -2000,7 +2013,9 @@ def advanced_search():
rating_low = int(rating_low) *2
q = q.filter(db.Books.ratings.any(db.Ratings.rating >= rating_low))
if description:
q
=
q
.
filter
(
db
.
Books
.
comments
.
any
(
db
.
Comments
.
text
.
ilike
(
"
%
"
+
description
+
"
%
"
)))
q = q.filter(db.Books.comments.any(db.or_(db.Comments.text.ilike("%" + description + "%"),
db.Comments.text.ilike("%" + unidecode.unidecode(description)
+ "%"))))
# search custom culumns
for c in cc:
...
...
@@ -2015,7 +2030,8 @@ def advanced_search():
db.cc_classes[c.id].value == custom_query ))
else:
q = q.filter(getattr(db.Books, 'custom_column_'+str(c.id)).any(
db
.
cc_classes
[
c
.
id
]
.
value
.
ilike
(
"
%
"
+
custom_query
+
"
%
"
)))
db.or_(db.cc_classes[c.id].value.ilike("%" + custom_query + "%"),
db.cc_classes[c.id].value.ilike("%" + unidecode.unidecode(custom_query) + "%"))))
q = q.all()
ids = list()
for element in q:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment