From a338131f288bb6b55abbe0f93341283ea8e76298 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 3 Apr 2016 15:01:02 +0200 Subject: [PATCH] sql: rename account last_login to last_earning this column name was confusing, add an index btw... beware with this commit, need mysql change + memcache restart --- sql/2016-04-03-accounts.sql | 7 +++++++ web/yaamp/core/backend/blocks.php | 2 +- web/yaamp/core/backend/renting.php | 2 +- web/yaamp/core/backend/stats.php | 2 +- web/yaamp/core/backend/users.php | 4 ++-- web/yaamp/modules/site/monsters.php | 2 +- web/yaamp/modules/site/payments_results.php | 10 ++++------ 7 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 sql/2016-04-03-accounts.sql diff --git a/sql/2016-04-03-accounts.sql b/sql/2016-04-03-accounts.sql new file mode 100644 index 0000000..4d09678 --- /dev/null +++ b/sql/2016-04-03-accounts.sql @@ -0,0 +1,7 @@ +-- Recent additions to add after db init (.gz) +-- mysql yaamp -p < file.sql + +ALTER TABLE `accounts` CHANGE COLUMN `last_login` `last_earning` INT(10) NULL; + +ALTER TABLE `accounts` ADD INDEX `earning` (`last_earning` DESC); + diff --git a/web/yaamp/core/backend/blocks.php b/web/yaamp/core/backend/blocks.php index 8e6bbe2..a6f6387 100644 --- a/web/yaamp/core/backend/blocks.php +++ b/web/yaamp/core/backend/blocks.php @@ -51,7 +51,7 @@ function BackendBlockNew($coin, $db_block) if (!$earning->save()) debuglog(__FUNCTION__.": Unable to insert earning!"); - $user->last_login = time(); + $user->last_earning = time(); $user->save(); } diff --git a/web/yaamp/core/backend/renting.php b/web/yaamp/core/backend/renting.php index 0ce7e6b..515d0b7 100644 --- a/web/yaamp/core/backend/renting.php +++ b/web/yaamp/core/backend/renting.php @@ -124,7 +124,7 @@ function BackendRentingPayout() // $value = yaamp_convert_amount_user($coin, $earning->amount, $user); - $user->last_login = time(); + $user->last_earning = time(); $user->balance += $value; $user->save(); } diff --git a/web/yaamp/core/backend/stats.php b/web/yaamp/core/backend/stats.php index e5350ab..4d607cf 100644 --- a/web/yaamp/core/backend/stats.php +++ b/web/yaamp/core/backend/stats.php @@ -323,7 +323,7 @@ function BackendStatsUpdate2() $tm = floor(time()/$step/60)*$step*60; $d = time()-24*60*60; - $list = getdbolist('db_accounts', "balance>0 or last_login>$d"); + $list = getdbolist('db_accounts', "balance>0 OR last_earning>$d"); foreach($list as $user) { $stats = getdbosql('db_balanceuser', "time=$tm and userid=$user->id"); diff --git a/web/yaamp/core/backend/users.php b/web/yaamp/core/backend/users.php index a1b6507..a9e882b 100644 --- a/web/yaamp/core/backend/users.php +++ b/web/yaamp/core/backend/users.php @@ -77,8 +77,8 @@ function BackendUsersUpdate() } // $delay=time()-60*60; -// $list = dborun("update coins set dontsell=1 where id in (select coinid from accounts where balance>0 or last_login>$delay group by coinid)"); -// $list = dborun("update coins set dontsell=0 where id not in (select coinid from accounts where balance>0 or last_login>$delay group by coinid)"); +// $list = dborun("UPDATE coins SET dontsell=1 WHERE id in (SELECT coinid FROM accounts WHERE balance>0 OR last_earning>$delay GROUP BY coinid)"); +// $list = dborun("UPDATE coins SET dontsell=0 WHERE id not in (SELECT coinid FROM accounts WHERE balance>0 OR last_earning>$delay GROUP BY coinid)"); // $list = getdbolist('db_workers', "dns is null"); diff --git a/web/yaamp/modules/site/monsters.php b/web/yaamp/modules/site/monsters.php index 62c4de3..23187c6 100644 --- a/web/yaamp/modules/site/monsters.php +++ b/web/yaamp/modules/site/monsters.php @@ -49,7 +49,7 @@ function showUser($userid, $what) $user = getdbo('db_accounts', $userid); if(!$user) return; - $d = datetoa2($user->last_login); + $d = datetoa2($user->last_earning); $balance = bitcoinvaluetoa($user->balance); $paid = dboscalar("select sum(amount) from payouts where account_id=$user->id"); $paid = bitcoinvaluetoa($paid); diff --git a/web/yaamp/modules/site/payments_results.php b/web/yaamp/modules/site/payments_results.php index d644f6f..0bcdfe1 100644 --- a/web/yaamp/modules/site/payments_results.php +++ b/web/yaamp/modules/site/payments_results.php @@ -1,7 +1,5 @@ 0 OR last_login > (UNIX_TIMESTAMP()-60*60) OR id IN (SELECT DISTINCT account_id FROM payouts WHERE tx IS NULL)". - ") ORDER BY last_login DESC limit 50"); + "balance > 0 OR last_earning > (UNIX_TIMESTAMP()-60*60) OR id IN (SELECT DISTINCT account_id FROM payouts WHERE tx IS NULL)". + ") ORDER BY last_earning DESC limit 50"); $total = 0.; $totalimmat = 0.; $totalfailed = 0.; foreach($list as $user) { $coin = getdbo('db_coins', $user->coinid); - $d = datetoa2($user->last_login); + $d = datetoa2($user->last_earning); echo ''; @@ -145,4 +143,4 @@ if ($coin_id) { echo 'Failed'.bitcoinvaluetoa($totalfailed)." $symbol"; echo ''; echo ''; -} \ No newline at end of file +}