From f4115b0edc1934f95c4be675c21af02731c96eee Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Thu, 31 Oct 2019 17:42:56 +0100 Subject: [PATCH] adjust channel ID lookup index channel claim id for claims --- server/controllers/lighthouse.js | 2 +- server/utils/chainquery/index.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/server/controllers/lighthouse.js b/server/controllers/lighthouse.js index 506e583..97c2262 100644 --- a/server/controllers/lighthouse.js +++ b/server/controllers/lighthouse.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()), }, }, diff --git a/server/utils/chainquery/index.js b/server/utils/chainquery/index.js index 08f989d..8e9e485 100644 --- a/server/utils/chainquery/index.js +++ b/server/utils/chainquery/index.js @@ -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,