From 61e3fa848c1c75fa1164e859f9d71d34b689fa6e Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 28 Jun 2019 22:25:38 -0700 Subject: [PATCH] modules/m_user: Determine the best query pattern for highlight count based on cache. --- modules/m_user.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/m_user.cc b/modules/m_user.cc index 14e9dc74b..796c4cc9e 100644 --- a/modules/m_user.cc +++ b/modules/m_user.cc @@ -145,10 +145,13 @@ ircd::m::user::highlight::count_between(const m::room &room, const event::idx_range &range) const { - static const event::fetch::opts fopts + static const event::fetch::opts fopts{[] { - event::keys::include {"type", "content"}, - }; + event::fetch::opts ret; + ret.keys = event::keys::include {"type", "content"}; + ret.query_json_force = true; + return ret; + }()}; m::room::messages it { @@ -177,7 +180,9 @@ const size_t ret{0}; for(++it; it && it.event_idx() < range.second; ++it) - ret += has(*it); + ret += cached(it.event_idx(), fopts)? + has(*it): + has(it.event_idx()); return ret; }