mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-57791 analytics: Changes after review
- Split model::predict in parts - JS promises updated according to eslint-plugin-promise - New API methods replacing direct DB queries - Reduce insights nav link display cost - Increase time limit as well as memory for big processes - Move prediction action event to core - Dataset write locking and others - Refine last time range end time - Removed dodgy splitting method id to int - Replace admin_setting_predictor output_html overwrite for write_setting overwrite - New APIs for access control - Discard invalid samples also during prediction
This commit is contained in:
parent
584ffa4ffc
commit
1611308b58
40 changed files with 513 additions and 289 deletions
|
@ -130,7 +130,8 @@ abstract class calculable {
|
|||
/**
|
||||
* Returns the number of weeks a time range contains.
|
||||
*
|
||||
* Useful for calculations that depend on the time range duration.
|
||||
* Useful for calculations that depend on the time range duration. Note that it returns
|
||||
* a float, rounding the float may lead to inaccurate results.
|
||||
*
|
||||
* @param int $starttime
|
||||
* @param int $endtime
|
||||
|
@ -141,9 +142,14 @@ abstract class calculable {
|
|||
throw new \coding_exception('End time timestamp should be greater than start time.');
|
||||
}
|
||||
|
||||
$diff = $endtime - $starttime;
|
||||
$starttimedt = new \DateTime();
|
||||
$starttimedt->setTimestamp($starttime);
|
||||
$starttimedt->setTimezone(\DateTimeZone::UTC);
|
||||
$endtimedt = new \DateTime();
|
||||
$endtimedt->setTimestamp($endtime);
|
||||
$endtimedt->setTimezone(\DateTimeZone::UTC);
|
||||
|
||||
// No need to be strict about DST here.
|
||||
$diff = $endtimedt->getTimestamp() - $starttimedt->getTimestamp();
|
||||
return $diff / WEEKSECS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue