Skip to content
Permalink
Browse files

adjust channel ID lookup

index channel claim id for claims
  • Loading branch information...
nikooo777 committed Oct 31, 2019
1 parent f1ad94d commit f4115b0edc1934f95c4be675c21af02731c96eee
Showing with 16 additions and 2 deletions.
  1. +1 −1 server/controllers/lighthouse.js
  2. +15 −1 server/utils/chainquery/index.js
@@ -48,7 +48,7 @@ function getResults (input) {
'bool': {
'must': {
'query_string': {
'fields': ['channel_id'],
'fields': ['channel_claim_id'],
'query' : getEscapedQuery(input.channel_id.trim()),
},
},
@@ -205,7 +205,20 @@ function getChainqueryConnection () {

function getClaimsSince (time, lastID, MaxClaimsInCall) {
return new Promise((resolve, reject) => {
let query = `SELECT c.id, c.name,p.name as channel, p.claim_id as channel_id, c.bid_state,c.effective_amount,COALESCE(p.effective_amount,1) as certificate_amount,c.claim_id as claimId,c.value_as_json as value FROM claim c LEFT JOIN claim p on p.claim_id = c.publisher_id WHERE c.id >${lastID} AND c.modified_at >='${time}' ORDER BY c.id LIMIT ${MaxClaimsInCall}`;
let query = `SELECT c.id,
c.name,
p.name as channel,
p.claim_id as channel_id,
c.bid_state,
c.effective_amount,
COALESCE(p.effective_amount,1) as certificate_amount,
c.claim_id as claimId,
c.value_as_json as value
FROM claim c LEFT JOIN claim p
on p.claim_id = c.publisher_id
WHERE c.id >${lastID} AND
c.modified_at >='${time}'
ORDER BY c.id LIMIT ${MaxClaimsInCall}`;
// Outputs full query to console for copy/paste into chainquery (debugging)
console.log(query);
getChainqueryConnection().query(query, function (err, results, fields) {
@@ -228,6 +241,7 @@ function getClaimsSince (time, lastID, MaxClaimsInCall) {
id : r.id,
name : r.name,
channel : r.channel,
channel_claim_id : r.channel_id,
bid_state : r.bid_state,
effective_amount : r.effective_amount,
certificate_amount: r.certificate_amount,

0 comments on commit f4115b0

Please sign in to comment.
You can’t perform that action at this time.