From 52ecd36422c7c6cc29093188b12c5607da66129e Mon Sep 17 00:00:00 2001 From: Joe Abbate Date: Mon, 8 Jan 2024 16:08:09 -0500 Subject: [PATCH 1/2] Dockerize Process Dump --- processDump.Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 processDump.Dockerfile diff --git a/processDump.Dockerfile b/processDump.Dockerfile new file mode 100644 index 0000000..3d535c0 --- /dev/null +++ b/processDump.Dockerfile @@ -0,0 +1,14 @@ +FROM php:7.4 + +RUN docker-php-ext-install mysqli + +WORKDIR /app + +COPY inc ./inc + +COPY inc/config.env.php inc/config.php + +COPY tools ./tools + +ENTRYPOINT ["php", "/app/tools/processDump.php", "-d"] + From 7bcb3a6eefded14374ce955141db2fb783b1e7d4 Mon Sep 17 00:00:00 2001 From: Mary Strodl Date: Mon, 8 Jan 2024 17:56:59 -0500 Subject: [PATCH 2/2] repeated calendar events --- api/src/Schedule.php | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/api/src/Schedule.php b/api/src/Schedule.php index c18d99e..16c3e11 100644 --- a/api/src/Schedule.php +++ b/api/src/Schedule.php @@ -34,6 +34,13 @@ private function firstDayAfterDate($weekday, $startDate) { return $startDate + (60*60*24*($weekday-$weekdayOfStart)); } + private function hashTime($time, $schedule) { + return ($time['start'] . "-" . + $time['end'] . "-" . + $time['bldg'][$schedule['bldgStyle']] . "-" . + $time['room']); + } + public function generateIcal($schedule) { date_default_timezone_set('America/New_York'); // Globals @@ -64,27 +71,44 @@ public function generateIcal($schedule) { continue; } - // Iterate over all the times + $scheduleByTime = array(); foreach($course['times'] as $time) { + $hash = $this->hashTime($time, $schedule); + // Add to scheduleByTime array + if (array_key_exists($hash, $scheduleByTime)) { + $scheduleByTime[$hash][] = $time; + } else { + $scheduleByTime[$hash] = array($time); + } + } + + // Iterate over all the times + foreach($scheduleByTime as $times) { $code .= "BEGIN:VEVENT\r\n"; $code .= "UID:" . md5(uniqid(mt_rand(), true) . " @{$HTTPROOTADDRESS}"); $code .= "\r\n"; $code .= "TZID:America/New_York\r\n"; $code .= "DTSTAMP:" . gmdate('Ymd') . "T" . gmdate("His") . "Z\r\n"; - $startTime = $this->icalFormatTime($time['start']); - $endTime = $this->icalFormatTime($time['end']); + $startTime = $this->icalFormatTime($times[0]['start']); + $endTime = $this->icalFormatTime($times[0]['end']); // The start day of the event MUST be offset by it's day // the -1 is b/c quarter starts are on Monday(=1) // This /could/ be done via the RRULE WKST param, but that means // translating days from numbers to some other esoteric format. // @TODO: Retrieve the timezone from php or the config file - $day = date("Ymd", $this->firstDayAfterDate($time['day'], $termStart)); + $day = date("Ymd", $this->firstDayAfterDate($times[0]['day'], $termStart)); $code .= "DTSTART;TZID=America/New_York:{$day}T{$startTime}\r\n"; $code .= "DTEND;TZID=America/New_York:{$day}T{$endTime}\r\n"; - $code .= "RRULE:FREQ=WEEKLY;UNTIL={$termEnd}\r\n"; + $dayCodes = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'); + $days = array(); + foreach ($times as $time) { + $days[] = $dayCodes[$time['day']]; + } + $dayString = implode(',', $days); + $code .= "RRULE:FREQ=WEEKLY;INTERVAL=1;WKST=SU;BYDAY={$dayString};UNTIL={$termEnd}\r\n"; $code .= "ORGANIZER:RIT\r\n"; // Course name @@ -96,8 +120,8 @@ public function generateIcal($schedule) { // Meeting location if($course['courseNum'] != 'non') { - $bldg = $time['bldg'][$schedule['bldgStyle']]; - $code .= "LOCATION:{$bldg}-{$time['room']}\r\n"; + $bldg = $times[0]['bldg'][$schedule['bldgStyle']]; + $code .= "LOCATION:{$bldg}-{$times[0]['room']}\r\n"; } $code .= "END:VEVENT\r\n";