mirror of
https://github.com/hkalexling/Mango.git
synced 2026-04-05 00:00:44 -04:00
Avoid N+1 queries problem
This commit is contained in:
@@ -8,11 +8,14 @@ class Title
|
||||
entries : Array(Entry), title : String, id : String,
|
||||
encoded_title : String, mtime : Time, signature : UInt64,
|
||||
entry_cover_url_cache : Hash(String, String)?
|
||||
setter entry_cover_url_cache : Hash(String, String)?
|
||||
setter entry_cover_url_cache : Hash(String, String)?,
|
||||
entry_sort_title_cache : Hash(String, String | Nil)?
|
||||
|
||||
@[YAML::Field(ignore: true)]
|
||||
@sort_title : String?
|
||||
@[YAML::Field(ignore: true)]
|
||||
@entry_sort_title_cache : Hash(String, String | Nil)?
|
||||
@[YAML::Field(ignore: true)]
|
||||
@entry_display_name_cache : Hash(String, String)?
|
||||
@[YAML::Field(ignore: true)]
|
||||
@entry_cover_url_cache : Hash(String, String)?
|
||||
@@ -324,6 +327,15 @@ class Title
|
||||
Storage.default.get_title_sort_title id
|
||||
end
|
||||
|
||||
def entry_sort_title_db(entry_id)
|
||||
unless @entry_sort_title_cache
|
||||
@entry_sort_title_cache =
|
||||
Storage.default.get_entries_sort_title @entries.map &.id
|
||||
end
|
||||
|
||||
@entry_sort_title_cache.not_nil![entry_id]?
|
||||
end
|
||||
|
||||
def tags
|
||||
Storage.default.get_title_tags @id
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user