Skip to content

Commit

Permalink
core: add estimated row counts to search results. (#3041)
Browse files Browse the repository at this point in the history
* core: add estimated row counts to search results.

Also fix an issue with the admin where changing the sort removed the selected page length.

* Add NL translation
  • Loading branch information
mworrell committed Jul 12, 2022
1 parent 72cdbbe commit 8f44438
Show file tree
Hide file tree
Showing 15 changed files with 612 additions and 338 deletions.
14 changes: 8 additions & 6 deletions include/zotonic.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,16 @@

%% @doc A set of search results
-record(search_result, {
search_name = 'query' :: atom(),
search_args = [] :: proplists:proplist(),
result = [] :: list(),
page = 1 :: pos_integer(),
pagelen :: pos_integer(),
total :: non_neg_integer(),
all :: non_neg_integer(),
pages :: non_neg_integer(),
next,
prev,
pagelen = ?SEARCH_PAGELEN :: pos_integer() | undefined,
total = undefined :: non_neg_integer() | undefined,
pages = undefined :: non_neg_integer() | undefined,
is_total_estimated = false :: boolean(),
next = false :: pos_integer() | false,
prev = 1 :: pos_integer(),
facets = [] :: list()
}).

Expand Down
2 changes: 2 additions & 0 deletions modules/mod_admin/templates/_admin_sort_header.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
qcustompivot=custompivot|default:q.qcustompivot|urlencode
qcat=q.qcat
qs=q.qs
qpagelen=q.qpagelen
qquery=q.qquery
%}{{ url_append }}">{{ caption }}{{ status_modifier_char }}</a>
{% endwith %}
{% endwith %}
Expand Down
1 change: 1 addition & 0 deletions modules/mod_admin/templates/admin_media.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
</tbody>
</table>
{% pager result=result dispatch="admin_media" qargs hide_single_page %}
<div class="text-muted clear-left"><b>{{ result.total }}</b> {_ items found _}{% if result.is_total_estimated %} ({_ estimated _}){% endif %}.</div>
{% endwith %}
{% endwith %}
</div>
Expand Down
5 changes: 3 additions & 2 deletions modules/mod_admin/templates/admin_overview.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,14 @@
{% with q.qsort as qsort %}
{% with m.rsc[q.qquery|default:`admin_overview_query`].id as qquery_id %}
{% with (qquery_id.is_visible and not q.qcat)|
if:{query query_id=qquery_id cat=qcat cat_exclude=qcat_exclude content_group=q.qgroup text=q.qs page=q.page pagelen=qpagelen sort=qsort zsort="-modified" custompivot=q.qcustompivot}
:{query authoritative=1 cat=qcat cat_exclude=qcat_exclude content_group=q.qgroup text=q.qs page=q.page pagelen=qpagelen sort=qsort zsort="-modified" custompivot=q.qcustompivot}
if:{query query_id=qquery_id cat=qcat cat_exclude=qcat_exclude content_group=q.qgroup text=q.qs page=q.page pagelen=qpagelen asort=qsort zsort="-modified" custompivot=q.qcustompivot}
:{query authoritative=1 cat=qcat cat_exclude=qcat_exclude content_group=q.qgroup text=q.qs page=q.page pagelen=qpagelen asort=qsort zsort="-modified" custompivot=q.qcustompivot}
as query
%}
{% with m.search.paged[query] as result %}
{% catinclude "_admin_overview_list.tpl" m.category[qcat].is_a result=result qsort=qsort qcat=qcat qcat_exclude=qcat_exclude custompivot=q.qcustompivot %}
{% pager result=result dispatch="admin_overview_rsc" qargs hide_single_page %}
<div class="text-muted clear-left"><b>{{ result.total }}</b> {_ items found _}{% if result.is_total_estimated %} ({_ estimated _}){% endif %}.</div>
{% endwith %}
{% endwith %}
{% endwith %}
Expand Down
1 change: 1 addition & 0 deletions modules/mod_admin/templates/admin_referrers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
</tbody>
</table>
{% pager result=result dispatch="admin_referrers" hide_single_page=1 id=q.id qargs %}
<div class="text-muted clear-left"><b>{{ result.total }}</b> {_ items found _}{% if result.is_total_estimated %} ({_ estimated _}){% endif %}.</div>
{% endifnotequal %}
</div>
{% endwith %}
Expand Down

0 comments on commit 8f44438

Please sign in to comment.