mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 11:25:29 -04:00
Fix lint
This commit is contained in:
parent
0f94288bab
commit
b711072492
@ -127,7 +127,8 @@ struct Tuple(*T)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias CacheableType = Array(Entry) | Array(Title) | String | Tuple(String, Int32)
|
alias CacheableType = Array(Entry) | Array(Title) | String |
|
||||||
|
Tuple(String, Int32)
|
||||||
alias CacheEntryType = SortedEntriesCacheEntry |
|
alias CacheEntryType = SortedEntriesCacheEntry |
|
||||||
SortedTitlesCacheEntry |
|
SortedTitlesCacheEntry |
|
||||||
CacheEntry(String, String) |
|
CacheEntry(String, String) |
|
||||||
|
@ -522,7 +522,9 @@ class Title
|
|||||||
|
|
||||||
case opt.not_nil!.method
|
case opt.not_nil!.method
|
||||||
when .title?
|
when .title?
|
||||||
ary = @entries.sort { |a, b| compare_numerically a.sort_title, b.sort_title }
|
ary = @entries.sort do |a, b|
|
||||||
|
compare_numerically a.sort_title, b.sort_title
|
||||||
|
end
|
||||||
when .time_modified?
|
when .time_modified?
|
||||||
ary = @entries.sort { |a, b| (a.mtime <=> b.mtime).or \
|
ary = @entries.sort { |a, b| (a.mtime <=> b.mtime).or \
|
||||||
compare_numerically a.sort_title, b.sort_title }
|
compare_numerically a.sort_title, b.sort_title }
|
||||||
|
@ -66,9 +66,9 @@ struct MainRouter
|
|||||||
percentage = title.load_percentage_for_all_entries username, sort_opt
|
percentage = title.load_percentage_for_all_entries username, sort_opt
|
||||||
title_percentage = title.titles.map &.load_percentage username
|
title_percentage = title.titles.map &.load_percentage username
|
||||||
title_percentage_map = {} of String => Float64
|
title_percentage_map = {} of String => Float64
|
||||||
title_percentage.each_with_index do |percentage, i|
|
title_percentage.each_with_index do |tp, i|
|
||||||
t = title.titles[i]
|
t = title.titles[i]
|
||||||
title_percentage_map[t.id] = percentage
|
title_percentage_map[t.id] = tp
|
||||||
end
|
end
|
||||||
|
|
||||||
layout "title"
|
layout "title"
|
||||||
|
@ -346,7 +346,9 @@ class Storage
|
|||||||
sort_title = nil
|
sort_title = nil
|
||||||
MainFiber.run do
|
MainFiber.run do
|
||||||
get_db do |db|
|
get_db do |db|
|
||||||
sort_title = db.query_one? "Select sort_title from titles where id = (?)", title_id, as: String | Nil
|
sort_title =
|
||||||
|
db.query_one? "Select sort_title from titles where id = (?)",
|
||||||
|
title_id, as: String | Nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sort_title
|
sort_title
|
||||||
@ -356,7 +358,8 @@ class Storage
|
|||||||
sort_title = nil if sort_title == ""
|
sort_title = nil if sort_title == ""
|
||||||
MainFiber.run do
|
MainFiber.run do
|
||||||
get_db do |db|
|
get_db do |db|
|
||||||
db.exec "update titles set sort_title = (?) where id = (?)", sort_title, title_id
|
db.exec "update titles set sort_title = (?) where id = (?)",
|
||||||
|
sort_title, title_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -365,7 +368,9 @@ class Storage
|
|||||||
sort_title = nil
|
sort_title = nil
|
||||||
MainFiber.run do
|
MainFiber.run do
|
||||||
get_db do |db|
|
get_db do |db|
|
||||||
sort_title = db.query_one? "Select sort_title from ids where id = (?)", entry_id, as: String | Nil
|
sort_title =
|
||||||
|
db.query_one? "Select sort_title from ids where id = (?)",
|
||||||
|
entry_id, as: String | Nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sort_title
|
sort_title
|
||||||
@ -375,7 +380,8 @@ class Storage
|
|||||||
results = Hash(String, String | Nil).new
|
results = Hash(String, String | Nil).new
|
||||||
MainFiber.run do
|
MainFiber.run do
|
||||||
get_db do |db|
|
get_db do |db|
|
||||||
db.query "select id, sort_title from ids where id in (#{ids.join "," { |id| "'#{id}'" }})" do |rs|
|
db.query "select id, sort_title from ids where id in " \
|
||||||
|
"(#{ids.join "," { |id| "'#{id}'" }})" do |rs|
|
||||||
rs.each do
|
rs.each do
|
||||||
id = rs.read String
|
id = rs.read String
|
||||||
sort_title = rs.read String | Nil
|
sort_title = rs.read String | Nil
|
||||||
@ -391,7 +397,8 @@ class Storage
|
|||||||
sort_title = nil if sort_title == ""
|
sort_title = nil if sort_title == ""
|
||||||
MainFiber.run do
|
MainFiber.run do
|
||||||
get_db do |db|
|
get_db do |db|
|
||||||
db.exec "update ids set sort_title = (?) where id = (?)", sort_title, entry_id
|
db.exec "update ids set sort_title = (?) where id = (?)",
|
||||||
|
sort_title, entry_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -86,7 +86,7 @@ def env_is_true?(key : String) : Bool
|
|||||||
val.downcase.in? "1", "true"
|
val.downcase.in? "1", "true"
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_titles(titles : Array(Title), opt : SortOptions, username : String) : Array(Title)
|
def sort_titles(titles : Array(Title), opt : SortOptions, username : String)
|
||||||
cache_key = SortedTitlesCacheEntry.gen_key username, titles, opt
|
cache_key = SortedTitlesCacheEntry.gen_key username, titles, opt
|
||||||
cached_titles = LRUCache.get cache_key
|
cached_titles = LRUCache.get cache_key
|
||||||
return cached_titles if cached_titles.is_a? Array(Title)
|
return cached_titles if cached_titles.is_a? Array(Title)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user