I have to update a lot of stocks via cron.
for example sake I will use smaller numbers:
let's say I have to update 100 symbols and I want the cron job to process 20 at a time and each stock updated once daily.
Based on your code
function stockapi_cron() {
if (time() - variable_get('stockapi_fetch_last', 0) > variable_get('stockapi_fetch', STOCKAPI_CRON_UPDATE_FREQUENCY)) {
$result = db_query_range('SELECT symbol FROM {stockapi_list} ORDER BY updated', 0, variable_get('stockapi_rows', STOCKAPI_CRON_ROWS_PER_FREQ));
while ($data = db_fetch_object($result)) {
if ($stock = stockapi_fetch($data->symbol)) {
stockapi_save($stock);
}
}
variable_set('stockapi_fetch_last', time());
cache_clear_all('variables', 'cache');
watchdog('cron', t('Stock API updated.'));
}
}
only 20 symbols would be updated per day instead of 5 cron runs totaling 100 symbols to make sure all symbols were updated once a day.
Am I understanding this correctly?
-Trevor
Comments
Comment #1
joseph.olstadIf you wish to continue to use the stock_api module, please upgrade to the latest release 7.x-2.x.
Previous releases relied upon Yahoo finance which no longer provides stock information. The new 7.x-2.x releases have a fix for that.