Formatting

This commit is contained in:
Alex Ling 2020-06-08 15:29:05 +00:00
parent 0f3dd51d6b
commit 926d0e66a5
2 changed files with 17 additions and 10 deletions

View File

@ -384,7 +384,8 @@ class Title
# TODO: More concise title?
def get_last_read_for_continue_reading(username, entry_obj)
last_read = load_last_read username, entry_obj.title
if last_read.nil? # grab from previous entry if current entry hasn't been started yet
# grab from previous entry if current entry hasn't been started yet
if last_read.nil?
previous_entry = previous_entry(entry_obj)
return load_last_read username, previous_entry.title if previous_entry
end
@ -519,7 +520,7 @@ class Library
{
entry: e,
percentage: e.book.load_percentage(username, e.title),
last_read: get_relevant_last_read(username, e)
last_read: get_relevant_last_read(username, e),
}
}
@ -532,7 +533,10 @@ class Library
}[0..11]
end
alias RA = NamedTuple(entry: Entry, percentage: Float64, grouped_count: Int32)
alias RA = NamedTuple(
entry: Entry,
percentage: Float64,
grouped_count: Int32)
def get_recently_added_entries(username)
entries = [] of Entry
@ -581,9 +585,11 @@ class Library
private def get_relevant_last_read(username, entry_obj)
last_read = entry_obj.book.load_last_read username, entry_obj.title
if last_read.nil? # grab from previous entry if current entry hasn't been started yet
# grab from previous entry if current entry hasn't been started yet
if last_read.nil?
previous_entry = entry_obj.book.previous_entry(entry_obj)
return entry_obj.book.load_last_read username, previous_entry.title if previous_entry
return entry_obj.book.load_last_read username, previous_entry.title \
if previous_entry
end
last_read
end

View File

@ -71,7 +71,8 @@ class MainRouter < Router
get "/" do |env|
begin
username = get_username env
continue_reading = @context.library.get_continue_reading_entries username
continue_reading = @context
.library.get_continue_reading_entries username
recently_added = @context.library.get_recently_added_entries username
titles = @context.library.titles
new_user = !titles.any? { |t| t.load_percentage(username) > 0 }