Skip to content

Commit

Permalink
add ability for NAWS to indicate that they have processed a deleted m…
Browse files Browse the repository at this point in the history
…eeting (#426)
  • Loading branch information
alanb2718 authored Aug 16, 2021
1 parent db0ea0a commit b3081bf
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ For instructions on installing the root server, see [Installing a New Root Serve
- Warning for an in-person meeting if there is information in a virtual meeting field.
- Warning for a virtual meeting (pure virtual, not hybrid or VM/TC) if there is a location or an address.
- Change default name for TC format from "Temporarily Closed" to "Temporarily Closed Facility"
- Add ability for NAWS to indicate that they have processed a deleted meeting, so that it stops showing up in future NAWS exports. To do this, the spreadsheet with updated World IDs should have a World ID of 'deleted' for deleted meetings they don't need to see again.

***Version 2.16.1* ** *- June 4, 2021*
- Require a key for HY, TC, and VM formats for every language, including additional format languages; make sure they have the correct world ID and type; make sure they can't be inadvertently mapped other formats.
Expand Down
25 changes: 19 additions & 6 deletions main_server/client_interface/csv/search_results_csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,10 @@ function ReturnNAWSFormatCSV(
/**
\brief Returns deleted meetings with NAWS IDs.
\description This queries every deleted meeting. The meetings returned are
not restricted to the search parameters, and may repeat from previous dumps.
Only meetings that had World IDs are returned.
\description This queries every deleted meeting. The meetings returned are not restricted to the search parameters,
and may repeat from previous dumps. Only meetings that had World IDs, and that don't have the World ID 'deleted'
in their most recent change record, are returned. (The special World ID 'deleted' indicates a meeting that NAWS
has already processed, and so they don't need to see it again.)
\returns An array of World IDs and change dates. These each represent deleted meetings.
*/
Expand All @@ -722,8 +723,10 @@ function ReturnNAWSDeletedMeetings(
$in_services ///< Any Service body IDs
) {
$ret = null;
$ids_to_ignore = []; // these are the IDs of meetings that NAWS has already processed, and so we don't output them

// We start by getting all the meetings that have been deleted (Could be quite a few).
// These are returned in reverse chronological order, with the most recent change first.
$changes = $server->GetChangesFromOTypeAndCType('c_comdef_meeting', 'comdef_change_type_delete');

if ($changes instanceof c_comdef_changes) {
Expand All @@ -747,9 +750,19 @@ function ReturnNAWSDeletedMeetings(
}
}
}

$value = intval(preg_replace('|\D*?|', '', $b_obj->GetMeetingDataValue('worldid_mixed')));

// If the meeting's ID is in $ids_to_ignore, we don't output it (not surprisingly).
// If the world_id for the meeting is 'deleted', that means that NAWS has already processed it,
// and we don't output it either; in addition, we add it to the $ids_to_ignore so that any earlier
// deletion change records for this meeting don't have anything output either.
if (in_array($b_obj->GetID(), $ids_to_ignore)) {
$value = false;
} else if ($b_obj->GetMeetingDataValue('worldid_mixed') === 'deleted') {
array_push($ids_to_ignore, $b_obj->GetID());
$value = false;
} else {
$value = intval(preg_replace('|\D*?|', '', $b_obj->GetMeetingDataValue('worldid_mixed')));
}

if ($value && $found) {
foreach ($in_transfer_dictionary as $key => $value2) {
if (($key != 'Delete')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ public function HandleMeetingWorldIDsUpdate()
'report' => array(
'updated' => array(),
'not_updated' => array(),
'not_found' => array()
'marked' => array(),
'not_found' => array(),
'not_marked' => array()
)
);

Expand Down Expand Up @@ -280,7 +282,15 @@ public function HandleMeetingWorldIDsUpdate()
try {
foreach ($meetingMap as $bmltId => $newWorldId) {
if (!array_key_exists($bmltId, $meetings)) {
$ret['report']['not_found'][] = $bmltId;
if ($newWorldId === 'deleted') {
if ($this->MarkDeletedMeetingAsHandled($bmltId)) {
$ret['report']['marked'][] = $bmltId;
} else {
$ret['report']['not_marked'][] = $bmltId;
}
} else {
$ret['report']['not_found'][] = $bmltId;
}
continue;
}

Expand All @@ -305,6 +315,39 @@ public function HandleMeetingWorldIDsUpdate()
return json_encode($ret);
}

/* Helper method for HandleMeetingWorldIDsUpdate. Mark a deleted meeting as handled, so that NAWS doesn't need to keep seeing
it in future exports. This is done by setting the world_id of the deleted meeting to 'deleted', so that the code that produces
a NAWS export file knows it can skip it (just as it skips deleted meetings with a blank world_id). Note that the deleted meeting
only exists in the changes table. Return true if it succeeded in marking a deleted meeting as handled, and false if not. This
doesn't try to be clever about working around problems: if something is wrong, it just returns false and doesn't make any changes.
This seems reasonable; the deleted meeting will just sit there as unmarked in that case. */
// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
private function MarkDeletedMeetingAsHandled($meeting_id)
{
$change_objects = c_comdef_server::GetChangesFromIDAndType('c_comdef_meeting', $meeting_id);
if ($change_objects instanceof c_comdef_changes) {
$obj_array = $change_objects->GetChangesObjects();
if (is_array($obj_array) && count($obj_array)) {
// The changes are returned in reverse chronological order. Ideally the last change would be a delete; but it seems
// that there can be race conditions in which there are several changes with the same time stamp. So get the
// most recent delete, rather than just $obj_array[0]
foreach ($obj_array as $change) {
if ($change instanceof c_comdef_change and $change->GetChangeType() === 'comdef_change_type_delete' and !$change->GetAfterObject()) {
$meeting = $change->GetBeforeObject();
if ($meeting->GetWorldID() === 'deleted') {
return false;
}
$meeting->SetWorldID('deleted');
$meeting->UpdateToDB();
$meeting->DeleteFromDB();
return true;
}
}
}
}
return false;
}

/*******************************************************************/
/**
\brief
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ public function return_main_console_html()
$ret .= 'var g_num_meetings_not_updated_text = \''.self::js_html($this->my_localized_strings['comdef_server_admin_strings']['server_admin_ui_num_meetings_not_updated']).'\';'.(defined('__DEBUG_MODE__') ? "\n" : '');
$ret .= 'var g_warning_text = \''.self::js_html($this->my_localized_strings['comdef_server_admin_strings']['server_admin_ui_warning']).'\';'.(defined('__DEBUG_MODE__') ? "\n" : '');
$ret .= 'var g_errors_text = \''.self::js_html($this->my_localized_strings['comdef_server_admin_strings']['server_admin_ui_errors']).'\';'.(defined('__DEBUG_MODE__') ? "\n" : '');
$ret .= 'var g_deleted_meetings_marked_text = \''.self::js_html($this->my_localized_strings['comdef_server_admin_strings']['server_admin_ui_deleted_meetings_marked']).'\';'.(defined('__DEBUG_MODE__') ? "\n" : '');
$ret .= 'var g_meetings_not_found_text = \''.self::js_html($this->my_localized_strings['comdef_server_admin_strings']['server_admin_ui_meetings_not_found']).'\';'.(defined('__DEBUG_MODE__') ? "\n" : '');
$ret .= 'var g_deleted_meetings_not_marked_text = \''.self::js_html($this->my_localized_strings['comdef_server_admin_strings']['server_admin_ui_deleted_meetings_not_marked']).'\';'.(defined('__DEBUG_MODE__') ? "\n" : '');
$ret .= 'var g_service_bodies_created_text = \''.self::js_html($this->my_localized_strings['comdef_server_admin_strings']['server_admin_ui_service_bodies_created']).'\';'.(defined('__DEBUG_MODE__') ? "\n" : '');
$ret .= 'var g_meetings_created_text = \''.self::js_html($this->my_localized_strings['comdef_server_admin_strings']['server_admin_ui_meetings_created']).'\';'.(defined('__DEBUG_MODE__') ? "\n" : '');
$ret .= 'var g_users_created_text = \''.self::js_html($this->my_localized_strings['comdef_server_admin_strings']['server_admin_ui_users_created']).'\';'.(defined('__DEBUG_MODE__') ? "\n" : '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
'server_admin_ui_num_meetings_not_updated' => 'Number of meetings that did not need updating: ',
'server_admin_ui_warning' => 'WARNING',
'server_admin_ui_errors' => 'Error(s)',
'server_admin_ui_deleted_meetings_marked' => 'Number of deleted meetings marked so that they won\'t appear in future NAWS exports: ',
'server_admin_ui_meetings_not_found' => 'meetings were found in the spreadsheet that did not exist in the database. This can happen when a meeting is deleted or unpublished. The missing meeting IDs are: ',
'server_admin_ui_deleted_meetings_not_marked' => 'tried to mark %d deleted meetings so that they wouldn\'t appear in future NAWS exports, but there was a problem (for example, meeting already marked or change record not found). The problem meeting IDs are: ',
'server_admin_ui_service_bodies_created' => 'Service bodies created: ',
'server_admin_ui_meetings_created' => 'Meetings created: ',
'server_admin_ui_users_created' => 'Users created: ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
'server_admin_ui_num_meetings_not_updated' => 'Number of meetings that did not need updating: ',
'server_admin_ui_warning' => 'WARNING',
'server_admin_ui_errors' => 'Error(s)',
'server_admin_ui_deleted_meetings_marked' => 'Number of deleted meetings marked so that they won\'t appear in future NAWS exports: ',
'server_admin_ui_meetings_not_found' => 'meetings were found in the spreadsheet that did not exist in the database. This can happen when a meeting is deleted or unpublished. The missing meeting IDs are: ',
'server_admin_ui_deleted_meetings_not_marked' => 'tried to mark %d deleted meetings so that they wouldn\'t appear in future NAWS exports, but there was a problem (for example, meeting already marked or change record not found). The problem meeting IDs are: ',
'server_admin_ui_service_bodies_created' => 'Service bodies created: ',
'server_admin_ui_meetings_created' => 'Meetings created: ',
'server_admin_ui_users_created' => 'Users created: ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
'server_admin_ui_num_meetings_not_updated' => 'Number of meetings that did not need updating: ',
'server_admin_ui_warning' => 'WARNING',
'server_admin_ui_errors' => 'Error(s)',
'server_admin_ui_deleted_meetings_marked' => 'Number of deleted meetings marked so that they won\'t appear in future NAWS exports: ',
'server_admin_ui_meetings_not_found' => 'meetings were found in the spreadsheet that did not exist in the database. This can happen when a meeting is deleted or unpublished. The missing meeting IDs are: ',
'server_admin_ui_deleted_meetings_not_marked' => 'tried to mark %d deleted meetings so that they wouldn\'t appear in future NAWS exports, but there was a problem (for example, meeting already marked or change record not found). The problem meeting IDs are: ',
'server_admin_ui_service_bodies_created' => 'Service bodies created: ',
'server_admin_ui_meetings_created' => 'Meetings created: ',
'server_admin_ui_users_created' => 'Users created: ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
'server_admin_ui_num_meetings_not_updated' => 'Number of meetings that did not need updating: ',
'server_admin_ui_warning' => 'WARNING',
'server_admin_ui_errors' => 'Error(s)',
'server_admin_ui_deleted_meetings_marked' => 'Number of deleted meetings marked so that they won\'t appear in future NAWS exports: ',
'server_admin_ui_meetings_not_found' => 'meetings were found in the spreadsheet that did not exist in the database. This can happen when a meeting is deleted or unpublished. The missing meeting IDs are: ',
'server_admin_ui_deleted_meetings_not_marked' => 'tried to mark %d deleted meetings so that they wouldn\'t appear in future NAWS exports, but there was a problem (for example, meeting already marked or change record not found). The problem meeting IDs are: ',
'server_admin_ui_service_bodies_created' => 'Service bodies created: ',
'server_admin_ui_meetings_created' => 'Meetings created: ',
'server_admin_ui_users_created' => 'Users created: ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
'server_admin_ui_num_meetings_not_updated' => 'Number of meetings that did not need updating: ',
'server_admin_ui_warning' => 'WARNING',
'server_admin_ui_errors' => 'Error(s)',
'server_admin_ui_deleted_meetings_marked' => 'Number of deleted meetings marked so that they won\'t appear in future NAWS exports: ',
'server_admin_ui_meetings_not_found' => 'meetings were found in the spreadsheet that did not exist in the database. This can happen when a meeting is deleted or unpublished. The missing meeting IDs are: ',
'server_admin_ui_deleted_meetings_not_marked' => 'tried to mark %d deleted meetings so that they wouldn\'t appear in future NAWS exports, but there was a problem (for example, meeting already marked or change record not found). The problem meeting IDs are: ',
'server_admin_ui_service_bodies_created' => 'Service bodies created: ',
'server_admin_ui_meetings_created' => 'Meetings created: ',
'server_admin_ui_users_created' => 'Users created: ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
'server_admin_ui_num_meetings_not_updated' => 'Number of meetings that did not need updating: ',
'server_admin_ui_warning' => 'WARNING',
'server_admin_ui_errors' => 'Error(s)',
'server_admin_ui_deleted_meetings_marked' => 'Number of deleted meetings marked so that they won\'t appear in future NAWS exports: ',
'server_admin_ui_meetings_not_found' => 'meetings were found in the spreadsheet that did not exist in the database. This can happen when a meeting is deleted or unpublished. The missing meeting IDs are: ',
'server_admin_ui_deleted_meetings_not_marked' => 'tried to mark %d deleted meetings so that they wouldn\'t appear in future NAWS exports, but there was a problem (for example, meeting already marked or change record not found). The problem meeting IDs are: ',
'server_admin_ui_service_bodies_created' => 'Service bodies created: ',
'server_admin_ui_meetings_created' => 'Meetings created: ',
'server_admin_ui_users_created' => 'Users created: ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
'server_admin_ui_num_meetings_not_updated' => 'Number of meetings that did not need updating: ',
'server_admin_ui_warning' => 'WARNING',
'server_admin_ui_errors' => 'Error(s)',
'server_admin_ui_deleted_meetings_marked' => 'Number of deleted meetings marked so that they won\'t appear in future NAWS exports: ',
'server_admin_ui_meetings_not_found' => 'meetings were found in the spreadsheet that did not exist in the database. This can happen when a meeting is deleted or unpublished. The missing meeting IDs are: ',
'server_admin_ui_deleted_meetings_not_marked' => 'tried to mark %d deleted meetings so that they wouldn\'t appear in future NAWS exports, but there was a problem (for example, meeting already marked or change record not found). The problem meeting IDs are: ',
'server_admin_ui_service_bodies_created' => 'Service bodies created: ',
'server_admin_ui_meetings_created' => 'Meetings created: ',
'server_admin_ui_users_created' => 'Users created: ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
'server_admin_ui_num_meetings_not_updated' => 'Liczba mityngów nie potrzebujących aktualizacji: ',
'server_admin_ui_errors' => 'Błędy',
'server_admin_ui_warning' => 'OSTRZEŻENIE',
'server_admin_ui_deleted_meetings_marked' => 'Number of deleted meetings marked so that they won\'t appear in future NAWS exports: ',
'server_admin_ui_meetings_not_found' => 'znaleziono mityngi w arkuszu, które nie istnieją w bazie danych. Może się to zdarzyć, gdy mityng jest usunięty lub niepubliczny. ID brakujących mityngów to: ',
'server_admin_ui_deleted_meetings_not_marked' => 'tried to mark %d deleted meetings so that they wouldn\'t appear in future NAWS exports, but there was a problem (for example, meeting already marked or change record not found). The problem meeting IDs are: ',
'server_admin_ui_service_bodies_created' => 'Utworzone organy służb: ',
'server_admin_ui_meetings_created' => 'Utworzone mityngi: ',
'server_admin_ui_users_created' => 'Utworzeni użytkownicy: ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
'server_admin_ui_num_meetings_not_updated' => 'Numero de reuniões que não precisam de atualização: ',
'server_admin_ui_warning' => 'AVISO',
'server_admin_ui_errors' => 'Erro(s)',
'server_admin_ui_deleted_meetings_marked' => 'Number of deleted meetings marked so that they won\'t appear in future NAWS exports: ',
'server_admin_ui_meetings_not_found' => 'reuniões foram encontradas na planilha que não existiam na base de dados. Isso pode acontecer quando uma reunião é apagada ou não publicada. Os IDs de reunião são: ',
'server_admin_ui_deleted_meetings_not_marked' => 'tried to mark %d deleted meetings so that they wouldn\'t appear in future NAWS exports, but there was a problem (for example, meeting already marked or change record not found). The problem meeting IDs are: ',
'server_admin_ui_service_bodies_created' => 'Corpos de serviço criados: ',
'server_admin_ui_meetings_created' => 'Reuniões criadas: ',
'server_admin_ui_users_created' => 'Usuários criados: ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
'server_admin_ui_num_meetings_not_updated' => 'Номера собраний, которые не нуждались в обновлении: ',
'server_admin_ui_warning' => 'ПРЕДУПРЕЖДЕНИЕ',
'server_admin_ui_errors' => 'Ошибка(и)',
'server_admin_ui_deleted_meetings_marked' => 'Number of deleted meetings marked so that they won\'t appear in future NAWS exports: ',
'server_admin_ui_meetings_not_found' => 'Собрания были найдены в таблице, которой не было в базе данных. Это могло произойти, если собрание удалено или не опубликовано. Не достающие ID собраний : ',
'server_admin_ui_deleted_meetings_not_marked' => 'tried to mark %d deleted meetings so that they wouldn\'t appear in future NAWS exports, but there was a problem (for example, meeting already marked or change record not found). The problem meeting IDs are: ',
'server_admin_ui_service_bodies_created' => 'Созданы сервисные органы: ',
'server_admin_ui_meetings_created' => 'Собрания созданы: ',
'server_admin_ui_users_created' => 'Пользователи создали: ',
Expand Down
Loading

0 comments on commit b3081bf

Please sign in to comment.