Skip to content

Commit

Permalink
check for valid timezone and add by-group in migration
Browse files Browse the repository at this point in the history
  • Loading branch information
KatjaGlassConsulting committed Jan 22, 2024
1 parent 3405e40 commit e3b7c56
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.0.1 to 1.0.2

- include check for valid timezones and take user timezone if lockdown-timezone is invalid
- update migration SQL to include additional group to support updates also on SQL option "only_full_group_by"

## 1.0.0 to 1.0.1

- performance updates
Expand Down
2 changes: 1 addition & 1 deletion Migrations/Version20231227114025.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function up(Schema $schema): void
SELECT ap.user_id, ap.start_date, ap.end_date, SUM(t.duration) AS dur_sum
FROM kimai2_ext_approval as ap, kimai2_timesheet AS t
WHERE ap.user_id = t.user AND t.start_time >= ap.start_date AND DATE_FORMAT(t.end_time,"%Y-%m-%d") <= ap.end_date
GROUP BY ap.user_id, ap.start_date
GROUP BY ap.user_id, ap.start_date, ap.end_date
) AS tm ON app.user_id = tm.user_id AND app.start_date = tm.start_date
SET app.actual_duration = tm.dur_sum');
}
Expand Down
8 changes: 7 additions & 1 deletion Repository/LockdownRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ private function updatePreference(User $user, string $preferenceName, string $va
*/
private function getOldestNotSubmittedDate(array $allWeeks, User $user): DateTime
{
$timezone = new DateTimeZone($user->getPreferenceValue('timezone'));
$timezoneValue = $user->getPreferenceValue('timezone');
$validTimezones = DateTimeZone::listIdentifiers();
if (!in_array($timezoneValue, $validTimezones)) {
$timezoneValue = $user->getTimezone();
}

$timezone = new DateTimeZone($timezoneValue);

foreach ($allWeeks as $week) {
if ($week['status'] === 'not_submitted') {
Expand Down

0 comments on commit e3b7c56

Please sign in to comment.