diff options
author | Arjun Satarkar <me@arjunsatarkar.net> | 2023-07-30 21:41:12 +0000 |
---|---|---|
committer | Arjun Satarkar <me@arjunsatarkar.net> | 2023-07-30 21:58:21 +0000 |
commit | e59a283db5f850dd791df021e22b599ecc70a824 (patch) | |
tree | c9a20c8e31b5cfd43abd13961d1ebd191d3a16aa /views | |
parent | 1910ead6204cb37e0a44b519e96eb1c526afffda (diff) | |
download | tagrss-e59a283db5f850dd791df021e22b599ecc70a824.tar tagrss-e59a283db5f850dd791df021e22b599ecc70a824.tar.gz tagrss-e59a283db5f850dd791df021e22b599ecc70a824.zip |
Get feed info for every displayed entry in one query, fix crash
Replacing the old approach where for every entry the title & tags were
queried separately. If 50 entries are displayed, this is 100 extra
queries that are now one query. If the maximum 1000 are displayed, this
is 2000 queries to one.
Benchmarking this change with
ab -n 500 -c 100 http://localhost:8000/?page_num=1&per_page=1000
with 1000+ entries present, we get:
(PREVIOUS) Time taken for tests: 0.840 seconds
(NEW) Time taken for tests: 0.476 seconds
The crash occurred when get_feeds() was called with get_tags=True and
the query returned at least one feed with no tags. This was not handled
properly by later code. It was not noticed when testing the previous
commit since all feeds in the test instance had one or more tags.
Diffstat (limited to 'views')
-rw-r--r-- | views/index.tpl | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/views/index.tpl b/views/index.tpl index 738adb6..0145a4e 100644 --- a/views/index.tpl +++ b/views/index.tpl @@ -116,7 +116,7 @@ </td> <td class="td-tags"> <div> - % tags = core.get_feed_tags(entry["feed_id"]) + % tags = referenced_feeds[entry["feed_id"]]["tags"] % for i, tag in enumerate(tags): % if i > 0: {{", "}} @@ -128,7 +128,8 @@ <td class="td-feed"> <div> <a href="/manage_feed?feed={{entry['feed_id']}}" class="no-visited-indication">⚙</a> - {{core.get_feed_title(entry["feed_id"])}} <small>(</small>{{entry["feed_id"]}}<small>)</small> + {{referenced_feeds[entry["feed_id"]]["title"]}} + <small>(</small>{{entry["feed_id"]}}<small>)</small> </div> </td> </tr> |