Handle nested titles in the recently added section

This commit is contained in:
Alex Ling 2020-06-11 10:03:34 +00:00
parent c9d3c35bdd
commit 5c26b0d6dc

View File

@ -191,6 +191,12 @@ class Title
@title_ids.map { |tid| @library.get_title! tid } @title_ids.map { |tid| @library.get_title! tid }
end end
# Get all entries, including entries in nested titles
def deep_entries
return @entries if title_ids.empty?
@entries + titles.map { |t| t.deep_entries }.flatten
end
def parents def parents
ary = [] of Title ary = [] of Title
tid = @parent_id tid = @parent_id
@ -535,7 +541,7 @@ class Library
def get_recently_added_entries(username) def get_recently_added_entries(username)
# Get all entries added within the last three months # Get all entries added within the last three months
entries = titles.map { |t| t.entries } entries = titles.map { |t| t.deep_entries }
.flatten .flatten
.select { |e| e.date_added > 3.months.ago } .select { |e| e.date_added > 3.months.ago }