use DB connector instead of web API #158

Merged
nikooo777 merged 11 commits from chainquery-db-connection into master 2019-10-31 20:57:53 +01:00
2 changed files with 16 additions and 2 deletions
Showing only changes of commit f4115b0edc - Show all commits

View file

@ -48,7 +48,7 @@ function getResults (input) {
'bool': { 'bool': {
'must': { 'must': {
'query_string': { 'query_string': {
'fields': ['channel_id'], 'fields': ['channel_claim_id'],
'query' : getEscapedQuery(input.channel_id.trim()), 'query' : getEscapedQuery(input.channel_id.trim()),
}, },
}, },

View file

@ -205,7 +205,20 @@ function getChainqueryConnection () {
function getClaimsSince (time, lastID, MaxClaimsInCall) { function getClaimsSince (time, lastID, MaxClaimsInCall) {
return new Promise((resolve, reject) => { 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) // Outputs full query to console for copy/paste into chainquery (debugging)
console.log(query); console.log(query);
getChainqueryConnection().query(query, function (err, results, fields) { getChainqueryConnection().query(query, function (err, results, fields) {
@ -228,6 +241,7 @@ function getClaimsSince (time, lastID, MaxClaimsInCall) {
id : r.id, id : r.id,
name : r.name, name : r.name,
channel : r.channel, channel : r.channel,
channel_claim_id : r.channel_id,
bid_state : r.bid_state, bid_state : r.bid_state,
effective_amount : r.effective_amount, effective_amount : r.effective_amount,
certificate_amount: r.certificate_amount, certificate_amount: r.certificate_amount,