Skip to content

Commit

Permalink
Fix admin search
Browse files Browse the repository at this point in the history
  • Loading branch information
NuckChorris committed Oct 26, 2024
1 parent d610ec0 commit 53a2a1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions app/models/anime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ def self.fuzzy_find(title)
end

def self.rails_admin_search(keyword)
where(id: TypesenseAnimeIndex.search(
find(TypesenseAnimeIndex.search(
query: keyword,
query_by: {
'canonical_title' => 100,
'titles.*' => 90,
'alternative_titles' => 90,
'descriptions.*' => 80
'alternative_titles' => 90
}
).sort({
'_text_match(buckets: 6)' => 'desc',
Expand Down
8 changes: 4 additions & 4 deletions app/models/manga.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ def self.unit_class
end

def self.rails_admin_search(keyword)
where(id: TypesenseMangaIndex.search(
find(TypesenseMangaIndex.search(
query: keyword,
query_by: {
'canonical_title' => 100,
'titles.*' => 90,
'alternative_titles' => 90,
'descriptions.*' => 80
'alternative_titles' => 90
}
).sort({
'_text_match(buckets: 6)' => 'desc',
'user_count' => 'desc'
}).include_fields(:id).load.hits.map { |res| res.document['id'] }) end
}).include_fields(:id).load.hits.map { |res| res.document['id'] })
end

def self.typesense_index
TypesenseMangaIndex
Expand Down

0 comments on commit 53a2a1a

Please sign in to comment.