Exchange rate actualizado

This commit is contained in:
Juan Ferrer Toribio 2017-09-13 09:51:57 +02:00
parent 7359dcb69a
commit e994cf0e38
3 changed files with 4 additions and 10 deletions

1
debian/cron.d vendored
View File

@ -5,4 +5,3 @@ MAILTO=webmaster
0 5 * * * root hedera-web.php -m edi/update 0 5 * * * root hedera-web.php -m edi/update
*/1 * * * * root hedera-web.php -m misc/mail */1 * * * * root hedera-web.php -m misc/mail
0 5 * * * root hedera-web.php -m misc/exchange-rate 0 5 * * * root hedera-web.php -m misc/exchange-rate
45 14 20 11 * root hedera-web.php -m misc/exchange-rate

View File

@ -3,7 +3,7 @@
/** /**
* Ejemplo: * Ejemplo:
* <Cube><Cube time="2010-12-10"><Cube currency="USD" rate="1.3244"/> * <Cube><Cube time="2010-12-10"><Cube currency="USD" rate="1.3244"/>
**/ */
class ExchangeRate extends Vn\Lib\Method class ExchangeRate extends Vn\Lib\Method
{ {
function run ($db) function run ($db)
@ -22,9 +22,9 @@ class ExchangeRate extends Vn\Lib\Method
{ {
$xmlDate = new DateTime ($cube['time']); $xmlDate = new DateTime ($cube['time']);
// Si existen datos más recientes de la máxima fecha los añade // Si existen datos más recientes de la máxima fecha los añade
if ($maxDate < $xmlDate) if ($maxDate <= $xmlDate)
foreach ($cube->Cube as $subCube) foreach ($cube->Cube as $subCube)
if ($subCube['currency'] == 'USD') if ($subCube['currency'] == 'USD')
{ {
@ -37,11 +37,6 @@ class ExchangeRate extends Vn\Lib\Method
VALUES (2, #date, #rate)', VALUES (2, #date, #rate)',
$params $params
); );
$db->query (
'REPLACE INTO reference_rate (moneda_id, date, rate)
VALUES (2, TIMESTAMPADD(DAY, 1, #date), #rate)',
$params
);
} }
} }

View File

@ -3,4 +3,4 @@ INSERT INTO reference_rate (moneda_id, date, rate)
FROM reference_rate r1 FROM reference_rate r1
LEFT JOIN reference_rate r2 LEFT JOIN reference_rate r2
ON TIMESTAMPADD(DAY, 1, r1.date) = r2.date ON TIMESTAMPADD(DAY, 1, r1.date) = r2.date
WHERE r2.date IS NULL AND r1.date < TIMESTAMPADD (DAY, -1, CURDATE()) WHERE r2.date IS NULL AND r1.date < TIMESTAMPADD (DAY, -2, CURDATE())