Searching results: improve ordering: token holders desc, name asc

pull/3231/head
Victor Baranov 4 years ago
parent 17f71985ea
commit 8ed7eb240b
  1. 2
      CHANGELOG.md
  2. 15
      apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex
  3. 2
      apps/block_scout_web/priv/gettext/default.pot
  4. 2
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  5. 8
      apps/explorer/lib/explorer/chain.ex

@ -7,7 +7,7 @@
### Fixes ### Fixes
- [#3231](https://github.com/poanetwork/blockscout/pull/3231) - Improve search: unlimited number of searching results - [#3231](https://github.com/poanetwork/blockscout/pull/3231) - Improve search: unlimited number of searching results
- [#3231](https://github.com/poanetwork/blockscout/pull/3231) - Improve search: allow search with space - [#3231](https://github.com/poanetwork/blockscout/pull/3231) - Improve search: allow search with space
- [#3231](https://github.com/poanetwork/blockscout/pull/3231) - Improve search: order by token holders in descendant order - [#3231](https://github.com/poanetwork/blockscout/pull/3231) - Improve search: order by token holders in descending order and token/contract name is ascending order
- [#3226](https://github.com/poanetwork/blockscout/pull/3226) - Fix notifier query for live update of token transfers - [#3226](https://github.com/poanetwork/blockscout/pull/3226) - Fix notifier query for live update of token transfers
- [#3220](https://github.com/poanetwork/blockscout/pull/3220) - Allow interaction with navbar menu at block-not-found page - [#3220](https://github.com/poanetwork/blockscout/pull/3220) - Allow interaction with navbar menu at block-not-found page

@ -179,7 +179,20 @@
value: "contract_address_hash", value: "contract_address_hash",
label: "contract_address_hash", label: "contract_address_hash",
descrSearch: true, descrSearch: true,
descr: "name" descr: "name",
sort: "function(x1, x2){
const tokenName1 = x1.split('<b>').length > 1 ? x1.split('<b>')[1].split('</b>')[0].toLowerCase() : ''
const tokenName2 = x2.split('<b>').length > 1 ? x2.split('<b>')[1].split('</b>')[0].toLowerCase() : ''
const holdersCount1 = x1.split('<i>').length > 1 ? parseInt(x1.split('<i>')[1].split('</i>')[0].split('holder')[0], 10) : null
const holdersCount2 = x2.split('<i>').length > 1 ? parseInt(x2.split('<i>')[1].split('</i>')[0].split('holder')[0], 10) : null
if (holdersCount1 && holdersCount2 && holdersCount1 !== holdersCount2 || (holdersCount1 && !holdersCount2) || (!holdersCount1 && holdersCount2)) {
holdersCount1 > holdersCount2
} else {
if (tokenName1 < tokenName2) { return -1 }
if (tokenName1 > tokenName2) { return 1 }
return 0
}
}"
]) %> ]) %>
<div class="input-group-append"> <div class="input-group-append">
<button class="input-group-text" id="search-icon"> <button class="input-group-text" id="search-icon">

@ -1244,7 +1244,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address_logs/index.html.eex:14 #: lib/block_scout_web/templates/address_logs/index.html.eex:14
#: lib/block_scout_web/templates/layout/_topnav.html.eex:172 #: lib/block_scout_web/templates/layout/_topnav.html.eex:172
#: lib/block_scout_web/templates/layout/_topnav.html.eex:190 #: lib/block_scout_web/templates/layout/_topnav.html.eex:203
msgid "Search" msgid "Search"
msgstr "" msgstr ""

@ -1244,7 +1244,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address_logs/index.html.eex:14 #: lib/block_scout_web/templates/address_logs/index.html.eex:14
#: lib/block_scout_web/templates/layout/_topnav.html.eex:172 #: lib/block_scout_web/templates/layout/_topnav.html.eex:172
#: lib/block_scout_web/templates/layout/_topnav.html.eex:190 #: lib/block_scout_web/templates/layout/_topnav.html.eex:203
msgid "Search" msgid "Search"
msgstr "" msgstr ""

@ -1046,7 +1046,13 @@ defmodule Explorer.Chain do
select: %{ select: %{
contract_address_hash: token.contract_address_hash, contract_address_hash: token.contract_address_hash,
symbol: token.symbol, symbol: token.symbol,
name: fragment("coalesce(?, '') || ' (' || coalesce(?, '') || ')'", token.name, token.symbol) name:
fragment(
"'<b>' || coalesce(?, '') || '</b>' || ' (' || coalesce(?, '') || ') ' || '<i>' || coalesce(?::varchar(255), '') || ' holder(s)' || '</i>'",
token.name,
token.symbol,
token.holder_count
)
}, },
order_by: [desc: token.holder_count] order_by: [desc: token.holder_count]
) )

Loading…
Cancel
Save