Skip to content

Commit

Permalink
Merge pull request #17 from eosdac/update_account_data
Browse files Browse the repository at this point in the history
Include is_member and has_voted on the holders table along with some account updates.
  • Loading branch information
piecesnbits committed Jan 23, 2019
2 parents f46a928 + b8df3a9 commit 570d9b4
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 17 deletions.
2 changes: 1 addition & 1 deletion api/explorer_base_api.php
Expand Up @@ -35,7 +35,7 @@
switch ($_GET['chart']) {

case 'topholders':
$stmt = $conn->prepare('SELECT account,balance FROM balances WHERE balance > 0 ORDER BY balance DESC LIMIT 500');
$stmt = $conn->prepare('SELECT account,balance,is_member,has_voted FROM balances WHERE balance > 0 ORDER BY balance DESC LIMIT 500');
break;
case 'tokenactivity':
$where = isset($_GET['account']) ? 'AND _from ="'.$_GET['account'].'" OR _to ="'.$_GET['account'].'"' : '';
Expand Down
14 changes: 7 additions & 7 deletions api/explorer_table_api.php
Expand Up @@ -27,18 +27,18 @@
break;

case 'hodlers':
$dt->query('SELECT account,balance, @curRank := @curRank + 1 AS rank FROM balances p, (SELECT @curRank := 0) r WHERE balance > 0 ORDER BY balance DESC');
$dt->query('SELECT account,balance,is_member,has_voted, @curRank := @curRank + 1 AS rank FROM balances p, (SELECT @curRank := 0) r WHERE balance > 0 ORDER BY balance DESC');
// $dt->query('SELECT account, balance FROM balances WHERE balance > 0');
break;
case 'transfers':
$dt->query('SELECT account_action_seq, _from, _to, _quantity, _symbol, _memo, txid, block_num, block_time FROM transfers ORDER BY account_action_seq DESC');
$dt->query('SELECT account_action_seq, _from, _to, _quantity, _symbol, _memo, txid, block_num, block_time FROM transfers ORDER BY account_action_seq DESC');
break;
case 'accounttransfers':
if (isset($_GET['account'])) {
$account = $_GET['account'];
// echo $account;
$dt->query('SELECT `account_action_seq`,`_from`,`_to`,`_quantity`,`_symbol`,`_memo`,`txid`,`block_num`,`block_time` FROM transfers WHERE _from="'.$account.'" OR _to="'.$account.'" ');
}
if (isset($_GET['account'])) {
$account = $_GET['account'];
// echo $account;
$dt->query('SELECT `account_action_seq`,`_from`,`_to`,`_quantity`,`_symbol`,`_memo`,`txid`,`block_num`,`block_time` FROM transfers WHERE _from="'.$account.'" OR _to="'.$account.'" ');
}
break;
}
}
Expand Down
4 changes: 3 additions & 1 deletion deamon/sql.txt
Expand Up @@ -16,10 +16,12 @@ CREATE TABLE `transfers` (
CREATE TABLE `balances` (
`account` varchar(256) NOT NULL,
`balance` decimal(13,4) DEFAULT NULL,
`is_member` tinyint(1) DEFAULT 0 NOT NULL,
`has_voted` tinyint(1) DEFAULT 0 NOT NULL,
`is_exchange` tinyint(1) DEFAULT 0 NOT NULL,
PRIMARY KEY (`account`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1


delimiter $$
$$
CREATE TRIGGER update_balance_table AFTER INSERT ON eosdac_explorer.transfers
Expand Down
28 changes: 22 additions & 6 deletions frontend/src/pages/account.vue
Expand Up @@ -48,14 +48,9 @@
<q-icon class="q-ma-sm text-mywhite2" style="font-size:45px;" name="icon-item-06"></q-icon>
</div>
<div class="col-xs-4 text-left">
<p class="q-mb-none q-mt-sm q-headline text-weight-light text-white big" style="line-height:24px;">0</p>
<p class="q-mb-none q-mt-sm q-headline text-weight-light text-white big" style="line-height:24px;">{{votes}}</p>
<span class="q-subheading">{{ $t('VOTES') }}</span>
</div>
<div class="col-xs-5 relative-position">

<p class="small q-mb-xs absolute" style="bottom:0;right:10px;">Coming Soon</p>
</div>

</div>
</div>
</div>
Expand Down Expand Up @@ -193,6 +188,7 @@ export default {
ismember: false,
eosdacbalance:0,
eosbalance:0,
votes:0,
filter: '',
loading: false,
serverPagination: {
Expand Down Expand Up @@ -223,6 +219,24 @@ export default {
},
getVotes(){
this.$eos.getTableRows({json: "true", scope: "daccustodian", code: "daccustodian", table: "votes", lower_bound: this.title, limit:1}).then(res =>{
if(!res.rows.length){
this.votes = 0;
return false;
}
else{
if (res.rows[0].voter === this.title){
this.votes = res.rows[0].candidates.length;
}
else{
this.votes = 0;
}
}
}).catch(e => {
this.$q.notify({message:this.$t('error_node_member'), color:'negative'});
})
},
getBalances(){
this.$eos.getCurrencyBalance({account: this.title, code: "eosdactokens", symbol: "EOSDAC"}).then(x=>{
if(x.length !=0){
Expand Down Expand Up @@ -302,6 +316,7 @@ export default {
});
this.getBalances();
this.getMemberStatus();
this.getVotes();
},
watch: {
Expand All @@ -313,6 +328,7 @@ watch: {
});
this.getBalances();
this.getMemberStatus();
this.getVotes();
}
},
Expand Down
16 changes: 14 additions & 2 deletions frontend/src/pages/hodlers.vue
Expand Up @@ -21,10 +21,20 @@
<router-link :to="{path: '/account/' + props.value}" >{{ props.value }}</router-link>
</q-td>

<q-td slot="body-cell-balance" slot-scope="props" :props="props" :style="{width:'80%'}">
<q-td slot="body-cell-balance" slot-scope="props" :props="props">
{{ props.value }}
</q-td>

<q-td slot="body-cell-is_member" slot-scope="props" :props="props">
<span v-if="props.value == 1">Yes</span>
<span v-if="props.value == 0">No</span>
</q-td>

<q-td slot="body-cell-has_voted" slot-scope="props" :props="props" :style="{width:'80%'}">
<span v-if="props.value == 1">Yes</span>
<span v-if="props.value == 0">No</span>
</q-td>

<template slot="top-right" slot-scope="props">
<q-search hide-underline v-model.trim="filter" />
<q-btn
Expand Down Expand Up @@ -77,7 +87,9 @@ export default {
columns: [
{ name: 'rank', label: '', field: 'rank', align: 'center', ignoreapi:true},
{ name: 'account', label: this.$t('account'), field: 'account', align: 'center', searchable:true},
{ name: 'balance', label: 'EOSDAC', field: 'balance' , align: 'left'}
{ name: 'balance', label: 'EOSDAC', field: 'balance' , align: 'left'},
{ name: 'is_member', label: 'Is Member?', field: 'is_member' , align: 'center'},
{ name: 'has_voted', label: 'Has Voted?', field: 'has_voted' , align: 'center'}
]
}
},
Expand Down

0 comments on commit 570d9b4

Please sign in to comment.