Merge pull request #4423 from blockscout/vb-search-contract-add-creation-time

Add creation time of contract in the results of the search
pull/4424/head
Victor Baranov 3 years ago committed by GitHub
commit 0991161d31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 8
      apps/block_scout_web/assets/js/lib/autocomplete.js
  3. 14
      apps/block_scout_web/assets/package-lock.json
  4. 1
      apps/block_scout_web/assets/package.json
  5. 8
      apps/explorer/lib/explorer/chain.ex

@ -1,6 +1,7 @@
## Current ## Current
### Features ### Features
- [#4423](https://github.com/blockscout/blockscout/pull/4423) - Add creation time of contract in the results of the search
- [#4391](https://github.com/blockscout/blockscout/pull/4391) - Add batched transactions on the `address/{addressHash}/transactions` page - [#4391](https://github.com/blockscout/blockscout/pull/4391) - Add batched transactions on the `address/{addressHash}/transactions` page
- [#4353](https://github.com/blockscout/blockscout/pull/4353) - Added live-reload on the token holders page - [#4353](https://github.com/blockscout/blockscout/pull/4353) - Added live-reload on the token holders page

@ -1,4 +1,5 @@
import AutoComplete from '@tarekraafat/autocomplete.js/dist/autoComplete.js' import AutoComplete from '@tarekraafat/autocomplete.js/dist/autoComplete.js'
import { DateTime } from 'luxon'
const placeHolder = 'Search by address, token symbol, name, transaction hash, or block number' const placeHolder = 'Search by address, token symbol, name, transaction hash, or block number'
const dataSrc = async (query, id) => { const dataSrc = async (query, id) => {
@ -44,10 +45,13 @@ const searchEngine = (query, record) => {
record.contract_address_hash.toLowerCase().includes(query.toLowerCase())) { record.contract_address_hash.toLowerCase().includes(query.toLowerCase())) {
var searchResult = `${record.contract_address_hash}<br/><b>${record.name}</b>` var searchResult = `${record.contract_address_hash}<br/><b>${record.name}</b>`
if (record.symbol) { if (record.symbol) {
searchResult = searchResult + ` (${record.symbol})` searchResult += ` (${record.symbol})`
} }
if (record.holder_count) { if (record.holder_count) {
searchResult = searchResult + ` <i>${record.holder_count} holder(s)</i>` searchResult += ` <i>${record.holder_count} holder(s)</i>`
}
if (record.inserted_at) {
searchResult += ` (${DateTime.fromISO(record.inserted_at).toLocaleString(DateTime.DATETIME_SHORT)})`
} }
var re = new RegExp(query, 'ig') var re = new RegExp(query, 'ig')
searchResult = searchResult.replace(re, '<mark class=\'autoComplete_highlight\'>$&</mark>') searchResult = searchResult.replace(re, '<mark class=\'autoComplete_highlight\'>$&</mark>')

@ -24,6 +24,7 @@
"humps": "^2.0.1", "humps": "^2.0.1",
"jquery": "^3.4.0", "jquery": "^3.4.0",
"lodash": "^4.17.19", "lodash": "^4.17.19",
"luxon": "^2.0.1",
"moment": "^2.29.1", "moment": "^2.29.1",
"nanomorph": "^5.4.0", "nanomorph": "^5.4.0",
"numeral": "^2.0.6", "numeral": "^2.0.6",
@ -11161,6 +11162,14 @@
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true "dev": true
}, },
"node_modules/luxon": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-2.0.1.tgz",
"integrity": "sha512-8Eawf81c9ZlQj62W3eq4mp+C7SAIAnmaS7ZuEAiX503YMcn+0C1JnMQRtfaQj6B5qTZLgHv0F4H5WabBCvi1fw==",
"engines": {
"node": "*"
}
},
"node_modules/make-dir": { "node_modules/make-dir": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
@ -26650,6 +26659,11 @@
} }
} }
}, },
"luxon": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-2.0.1.tgz",
"integrity": "sha512-8Eawf81c9ZlQj62W3eq4mp+C7SAIAnmaS7ZuEAiX503YMcn+0C1JnMQRtfaQj6B5qTZLgHv0F4H5WabBCvi1fw=="
},
"make-dir": { "make-dir": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",

@ -36,6 +36,7 @@
"humps": "^2.0.1", "humps": "^2.0.1",
"jquery": "^3.4.0", "jquery": "^3.4.0",
"lodash": "^4.17.19", "lodash": "^4.17.19",
"luxon": "^2.0.1",
"moment": "^2.29.1", "moment": "^2.29.1",
"nanomorph": "^5.4.0", "nanomorph": "^5.4.0",
"numeral": "^2.0.6", "numeral": "^2.0.6",

@ -1130,8 +1130,14 @@ defmodule Explorer.Chain do
{:some, term} -> {:some, term} ->
query = query =
from(smart_contract in SmartContract, from(smart_contract in SmartContract,
left_join: address in Address,
on: smart_contract.address_hash == address.hash,
where: fragment("to_tsvector(name ) @@ to_tsquery(?)", ^term), where: fragment("to_tsvector(name ) @@ to_tsquery(?)", ^term),
select: %{contract_address_hash: smart_contract.address_hash, name: smart_contract.name}, select: %{
contract_address_hash: smart_contract.address_hash,
name: smart_contract.name,
inserted_at: address.inserted_at
},
order_by: [desc: smart_contract.inserted_at] order_by: [desc: smart_contract.inserted_at]
) )

Loading…
Cancel
Save