def authors_index(start): q = model.Author.query q = q.filter( func.unaccent(model.Author.last_name + ', ' + model.Author.first_name).ilike( func.unaccent(start + '%'))).order_by( model.Author.last_name, model.Author.first_name) return run_query_limited(q)
def shelves_index(start, user): q = model.Bookshelf.query if user: q=q.filter(model.Bookshelf.created_by == user) else: q=q.filter(model.Bookshelf.public == True, model.Bookshelf.created_by != user) q = q.filter(func.unaccent(model.Bookshelf.name).ilike( func.unaccent(start + '%'))).order_by(model.Bookshelf.name) return run_query_limited(q)
def series_index(start): # Need to add authors # select distinct series.*, author.id as author_id, author.first_name, # author.last_name from series left join ebook on series.id = # ebook.series_id join ebook_authors on ebook_authors.ebook_id=ebook.id # join author on author.id = ebook_authors.author_id; q = model.Series.query q = q.filter(func.unaccent(model.Series.title).ilike( func.unaccent(start + '%'))).order_by(model.Series.title) return run_query_limited(q)
def shelves_index(start, user): q = model.Bookshelf.query if user: q = q.filter(model.Bookshelf.created_by == user) else: q = q.filter(model.Bookshelf.public == True, model.Bookshelf.created_by != user) q = q.filter( func.unaccent(model.Bookshelf.name).ilike( func.unaccent(start + '%'))).order_by(model.Bookshelf.name) return run_query_limited(q)
def series_index(start): # Need to add authors # select distinct series.*, author.id as author_id, author.first_name, # author.last_name from series left join ebook on series.id = # ebook.series_id join ebook_authors on ebook_authors.ebook_id=ebook.id # join author on author.id = ebook_authors.author_id; q = model.Series.query q = q.filter( func.unaccent(model.Series.title).ilike( func.unaccent(start + '%'))).order_by(model.Series.title) return run_query_limited(q)
def find_area(): """ :return: """ try: search_name = "%{}%".format(request.args.get("q")) search_code = request.args.get("q") qarea = (DB.session.query( MVLAreasAutocomplete.id, MVLAreasAutocomplete.type_name, MVLAreasAutocomplete.type_desc, MVLAreasAutocomplete.type_code, MVLAreasAutocomplete.area_name, MVLAreasAutocomplete.area_code, ).filter( or_( MVLAreasAutocomplete.search_area_name.like( func.unaccent(search_name.lower())), MVLAreasAutocomplete.area_code == search_code, )).limit(20)) print(qarea) result = qarea.all() count = len(result) datas = [] for r in result: datas.append(r._asdict()) return {"count": count, "datas": datas}, 200 except Exception as e: current_app.logger.error("<find_area> ERROR:", e) return {"Error": str(e)}, 400
def filter_shelves(q, filter): return q.filter(func.unaccent(model.Bookshelf.name).ilike(func.unaccent(text("'%%%s%%'" % filter))))
def filter_ebooks(q, filter): return q.filter(func.unaccent(model.Ebook.title).ilike(func.unaccent(text("'%%%s%%'" % filter))))
def authors_index(start): q = model.Author.query q = q.filter(func.unaccent(model.Author.last_name + ', ' + model.Author.first_name) .ilike(func.unaccent(start + '%'))).order_by(model.Author.last_name, model.Author.first_name) return run_query_limited(q)
def ebooks_index(start): q = model.Ebook.query q = q.filter(func.unaccent(model.Ebook.title).ilike( func.unaccent(start + '%'))).order_by(model.Ebook.title) return run_query_limited(q)
def filter_shelves(q, filter): return q.filter( func.unaccent(model.Bookshelf.name).ilike( func.unaccent(text("'%%%s%%'" % filter))))
def filter_ebooks(q, filter): return q.filter( func.unaccent(model.Ebook.title).ilike( func.unaccent(text("'%%%s%%'" % filter))))
def ebooks_index(start): q = model.Ebook.query q = q.filter( func.unaccent(model.Ebook.title).ilike( func.unaccent(start + '%'))).order_by(model.Ebook.title) return run_query_limited(q)
def _similarity(query, text): return func.word_similarity(func.unaccent(query), func.unaccent(text))
def _similarity(statement, text): return func.word_similarity(func.unaccent(statement), func.unaccent(text))
def series_index(start): q = model.Series.query q = q.filter(func.unaccent(model.Series.title).ilike( func.unaccent(start + '%'))).order_by(model.Series.title) return _run_query(q)