0
1
Fork 0

Merge pull request 'feat: refs #7108 deletes exchange-rate' (!59) from 7108 into test

Reviewed-on: verdnatura/hedera-web#59
Reviewed-by: Juan Ferrer <juan@verdnatura.es>
This commit is contained in:
Juan Ferrer 2024-05-14 08:51:27 +00:00
commit ac226205b0
5 changed files with 7 additions and 52 deletions

View File

@ -5,9 +5,12 @@ Hedera is the main web shop page for Verdnatura.
## Prerequisites
Required applications.
* PHP >= 7.0
* Node.js >= 8.0
* [php-vn-lib](https://gitea.verdnatura.es/verdnatura/php-vn-lib)
* PHP >= 8.4
* Node.js >= 20.0
Take a look to *debian/control* file to see additional dependencies.
Copy config.php to *config.my.php* and place your DB config there.
### Installing dependencies and launching

View File

@ -24,7 +24,7 @@ return [
,'port' => 3306
,'schema' => 'hedera'
,'user' => 'hedera-web'
,'pass' => ''
,'pass' => '' // base64 encoded
,'tz' => 'Europe/madrid'
]
];

1
debian/cron.d vendored
View File

@ -3,7 +3,6 @@ MAILTO=webmaster
*/2 * * * * root hedera-web.php -m edi/load
0 23 * * * root hedera-web.php -m edi/clean
0 5 * * * root hedera-web.php -m edi/update
0 5 * * * root hedera-web.php -m misc/exchange-rate
0 0 * * * root hedera-web.php -m image/sync
0 1 * * * root /usr/share/hedera-web/utils/image-clean.sh > /dev/null
0 */1 * * * root /usr/share/hedera-web/utils/update-browscap.sh > /dev/null

View File

@ -1,41 +0,0 @@
<?php
/**
* Ejemplo:
* <Cube><Cube time="2010-12-10"><Cube currency="USD" rate="1.3244"/>
*/
class ExchangeRate extends Vn\Lib\Method {
function run($db) {
$db->selectDb('vn');
// Indica la URL del archivo
$xml = new SimpleXMLElement(
'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml', 0, TRUE);
$date = $db->getValue("SELECT MAX(dated) fecha FROM referenceRate");
$maxDate = $date ? DateTime::createFromFormat('Y-m-d', $date) : NULL;
foreach ($xml->Cube[0]->Cube as $cube) {
$xmlDate = new DateTime($cube['time']);
// Si existen datos más recientes de la máxima fecha los añade
if ($maxDate <= $xmlDate)
foreach ($cube->Cube as $subCube)
if ($subCube['currency'] == 'USD') {
$params = [
'date' => $xmlDate,
'rate' => $subCube['rate']
];
$db->query(
'REPLACE INTO referenceRate(currencyFk, dated, `value`)
VALUES(2, #date, #rate)',
$params
);
}
}
$db->queryFromFile(__DIR__.'/exrate-add');
}
}

View File

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