Skip to content

Commit

Permalink
Organize meeting data by event_id as well as date
Browse files Browse the repository at this point in the history
This adds another level of organization to the meeting data feed.  Meetings are now organized by date and event_id.  Meetings that are not in Google Calendar will have an event_id of zero.  This means if there are multiple meetings on the same day that are not in a calendar, they will still be lumped together.

We do not have time information in the database for meetingFiles.  However, for meetings that are in Google Calendar, we can display the start time of the event.
Ultimately, we need to do a database schema change to change the meetingFiles.date column to be a datetime.  Then we'll need to run through all the Google Calendar events and populate the datetime information.

Until then, the only place we do not have the time information is on the MeetingFiles/Index controller.  That is purely reading from the database.

Updates #310
  • Loading branch information
inghamn committed Feb 1, 2022
1 parent 5fa5f5f commit c0cdb2c
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 59 deletions.
38 changes: 20 additions & 18 deletions blocks/html/committees/meetings.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @copyright 2017-2019 City of Bloomington, Indiana
* @copyright 2017-2022 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
* @param Committee $htis->committee
* @param array $this->meetings
Expand All @@ -27,25 +27,27 @@ use Web\Url;
</header>
<?php
$block = new Block('meetingFiles/meetingTypeFiles.inc', ['committee'=>$this->committee]);
foreach ($this->meetings as $date=>$meeting) {
$d = new \DateTime($date);
echo "
<div class=\"meeting\">
<h2><span class=\"month\">{$d->format('F')}</span>
<span class=\"day\">{$d->format('j')}</span>
</h2>
";
foreach ($this->meetings as $date=>$day) {
foreach ($day as $event_id=>$meeting) {
$d = new \DateTime($date);
echo "
<div class=\"meeting\">
<h2><span class=\"month\">{$d->format('F')}</span>
<span class=\"day\">{$d->format('j')}</span>
</h2>
";

$block->date = $d;
$block->eventId = !empty($meeting['eventId']) ? $meeting['eventId'] : '';
foreach (MeetingFile::$types as $type) {
$block->type = $type;
$block->files = !empty($meeting['files'][$type]) ? $meeting['files'][$type] : [];
echo $block->render('html', $this->template);
$block->date = $d;
$block->eventId = !empty($meeting['eventId']) ? $meeting['eventId'] : '';
foreach (MeetingFile::$types as $type) {
$block->type = $type;
$block->files = !empty($meeting['files'][$type]) ? $meeting['files'][$type] : [];
echo $block->render('html', $this->template);
}
echo "
</div>
";
}
echo "
</div>
";
}
?>
</section>
10 changes: 6 additions & 4 deletions blocks/html/meetingFiles/updateForm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ $heading = $id ? $this->_('meetingFile_edit') : $this->_('meetingFile_add');

$meetings = $committee->getMeetings($start, $end);
$options = [['value'=>'']];
foreach ($meetings as $d=>$m) {
if (!empty($m['eventId'])) {
$date = new \DateTime($d);
$options[] = ['value'=>$m['eventId'], 'label'=>$date->format('F j Y')];
foreach ($meetings as $date=>$day) {
foreach ($day as $event_id=>$m) {
if (!empty($m['eventId'])) {
$start = new \DateTime($m['start']);
$options[] = ['value'=>$m['eventId'], 'label'=>$start->format('F j Y g:i a')];
}
}
}

Expand Down
30 changes: 3 additions & 27 deletions blocks/json/committees/meetings.inc
Original file line number Diff line number Diff line change
@@ -1,33 +1,9 @@
<?php
/**
* @copyright 2017 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @copyright 2017-2022 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
* @param Committee $htis->committee
* @param array $this->meetings
* @param int $this->year
*/
use Application\Models\MeetingFile;

use Web\Block;
use Web\Url;


$out = [];
foreach ($this->meetings as $date=>$meeting) {

$out[$date]['eventId' ] = !empty($meeting['eventId' ]) ? $meeting['eventId' ] : '';
$out[$date]['summary' ] = !empty($meeting['summary' ]) ? $meeting['summary' ] : '';
$out[$date]['location'] = !empty($meeting['location']) ? $meeting['location'] : '';
$out[$date]['start' ] = !empty($meeting['start' ]) ? $meeting['start' ] : '';
$out[$date]['end' ] = !empty($meeting['end' ]) ? $meeting['end' ] : '';
$out[$date]['htmlLink'] = !empty($meeting['htmlLink']) ? $meeting['htmlLink'] : '';

foreach (MeetingFile::$types as $type) {
if (!empty( $meeting['files'][$type])) {
foreach ($meeting['files'][$type] as $file) {
$out[$date]['files'][$type][] = $file->getData();
}
}
}
}
echo json_encode($out, JSON_PRETTY_PRINT);
echo json_encode($this->meetings, JSON_PRETTY_PRINT);
4 changes: 2 additions & 2 deletions src/Application/Controllers/CommitteesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ public function meetings(): View

$this->template->title = $committee->getName();
if ($this->template->outputFormat == 'html') {
$this->template->blocks[] = new Block('committees/breadcrumbs.inc', ['committee' => $committee]);
$this->template->blocks[] = new Block('committees/header.inc', ['committee' => $committee]);
header("Location: ".View::generateUrl('meetingFiles.index'));
exit();
}
$this->template->blocks[] = new Block('committees/meetings.inc', [
'committee' => $committee,
Expand Down
25 changes: 18 additions & 7 deletions src/Application/Models/Committee.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @copyright 2009-2021 City of Bloomington, Indiana
* @copyright 2009-2022 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
*/
declare (strict_types=1);
Expand Down Expand Up @@ -405,9 +405,18 @@ public static function data(array $fields=null)
}

/**
* Returns meeting information for a date range.
*
* Meetings are organizd by date and event_id. For meetings without
* a Google Calendar event, the event_id is zero. This means, if
* there are multiple meetings on the same day, that are not in a
* Calendar, they will all be lumped together as a single meeting.
*
* $meetings[date][event_id][..]
*
* @return array An array of meeting dates
*/
public function getMeetings(\DateTime $start, \DateTime $end)
public function getMeetings(\DateTime $start, \DateTime $end): array
{
$meetings = [];

Expand All @@ -424,11 +433,11 @@ public function getMeetings(\DateTime $start, \DateTime $end)
$eventStart = new \DateTime($e->start->date);
$eventEnd = new \DateTime($e->end ->date);
}
$year = $eventStart->format('Y');
$month = $eventStart->format('m');
$day = $eventStart->format('d');

$meetings[$eventStart->format('Y-m-d')] = [
$date = $eventStart->format('Y-m-d');
$event_id = $e->id;

$meetings[$date][$event_id] = [
'eventId' => $e->id,
'summary' => $e->summary,
'location' => $e->location,
Expand All @@ -442,7 +451,9 @@ public function getMeetings(\DateTime $start, \DateTime $end)
$table = new MeetingFilesTable();
$list = $table->find(['start'=>$start, 'end'=>$end, 'committee_id'=>$this->getId()]);
foreach ($list as $f) {
$meetings[$f->getMeetingDate('Y-m-d')]['files'][$f->getType()][] = $f;
$date = $f->getMeetingDate('Y-m-d');
$event_id = $f->getEventId() ?? 0;
$meetings[$date][$event_id]['files'][$f->getType()][] = $f->getData();
}
ksort($meetings);

Expand Down
1 change: 0 additions & 1 deletion src/Web/Search/Solr.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public function query(string $search,
}

$req = $this->client->createRequest($query);
error_log($req->getUri());
return $this->client->execute($query);
}

Expand Down

0 comments on commit c0cdb2c

Please sign in to comment.