Page MenuHomePhabricator

Implement strategy to account for DST variations
Closed, ResolvedPublic

Description

Work items as defined in the investigation from T314871:

1 - Add the new columns to save the local time, timezone of the local time, and its UTC conversion, and change the code as needed to display the right information for the user.

Acceptance criteria

  • Create the new columns on campaign_events table:
    • event_start_local
    • event_start_utc
    • event_end_local
    • event_end_utc
    • event_timezone
  • Change the code as needed to save the data on the new columns
  • Change the code as needed to display the right information for the user
  • Update documentation of the endpoints:
    • Add the timezone to the response of "get details of an event"
    • Note that start and end time are local in "get details of an event" and the 2 endpoints for enabling/editing an event

Deployment plan

  • Write the patch that changes the schema in the code. Review it, but DO NOT MERGE IT. Only give it a +1, explicitly writing in a comment that the +1 means you are approving the change (and not that you have a working mouse).
  • Create the new columns on beta with default values (see below)
  • Merge the patch and wait for it to reach beta
  • Remove default values on beta
  • Update the beta DB with the actual values for the new columns (can be copied from the old columns)

ALTERs to run on beta

Before merging the patch:

-- Add new columns with temporary defaults used until the patch is merged
ALTER TABLE campaign_events ADD COLUMN event_timezone VARBINARY(64) NOT NULL DEFAULT 'UTC' AFTER event_status;
ALTER TABLE campaign_events ADD COLUMN event_start_local BINARY(14) NOT NULL DEFAULT '20220815100000' AFTER event_timezone;
ALTER TABLE campaign_events ADD COLUMN event_start_utc BINARY(14) NOT NULL DEFAULT '20220815110000' AFTER event_start_local;
ALTER TABLE campaign_events ADD COLUMN event_end_local BINARY(14) NOT NULL DEFAULT '20220815120000' AFTER event_start_utc;
ALTER TABLE campaign_events ADD COLUMN event_end_utc BINARY(14) NOT NULL DEFAULT '20220815130000' AFTER event_end_local;
-- Add defaults to the existing columns for later; use a unique value that identifies new rows
ALTER TABLE campaign_events ALTER COLUMN event_start SET DEFAULT '00000000000000';
ALTER TABLE campaign_events ALTER COLUMN event_end SET DEFAULT '00000000000000';
CREATE INDEX event_timezone_id ON /*_*/campaign_events (event_timezone, event_id);

(Note: once the patch reaches beta, event times will be wrong until the queries below are executed)

After merging the patch:

-- Copy data for the old rows to the new columns
UPDATE campaign_events SET event_start_utc=event_start, event_start_local=event_start, event_end_utc=event_end, event_end_local=event_end WHERE event_start != '00000000000000';
-- Drop old columns
ALTER TABLE campaign_events DROP COLUMN event_start;
ALTER TABLE campaign_events DROP COLUMN event_end;
-- Drop defaults from the new columns
ALTER TABLE campaign_events ALTER event_timezone DROP DEFAULT;
ALTER TABLE campaign_events ALTER event_start_local DROP DEFAULT;
ALTER TABLE campaign_events ALTER event_start_utc DROP DEFAULT;
ALTER TABLE campaign_events ALTER event_end_local DROP DEFAULT;
ALTER TABLE campaign_events ALTER event_end_utc DROP DEFAULT;
NOTE: Since we're not doing this in a backwards-compatible way, you will have to alter the tables manually on your local once the patch is merged

Event Timeline

ifried renamed this task from Change storage of timestamps to account for DST variations to Change storage of timestamps to account for DST variations (V1).Jun 30 2022, 3:45 PM
ifried added a project: Campaign-Tools.
ldelench_wmf moved this task from V1 (MVP) to Darkship on the Campaign-Registration board.
vyuen renamed this task from Change storage of timestamps to account for DST variations (V1) to Implement strategy to account for DST variations.Aug 30 2022, 5:03 PM
vyuen lowered the priority of this task from High to Medium.Aug 31 2022, 9:37 AM
vyuen moved this task from Darkship to V1 (MVP) on the Campaign-Registration board.

Change 828644 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/CampaignEvents@master] Create new columns to store local times and timezone

https://gerrit.wikimedia.org/r/828644

Change 828649 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/CampaignEvents@master] Harmonize format of start and end timestamp

https://gerrit.wikimedia.org/r/828649

Daimona updated the task description. (Show Details)

Change 829014 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/CampaignEvents@master] Introduce distinction between local and UTC time

https://gerrit.wikimedia.org/r/829014

Change 828649 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Harmonize format of start and end timestamp

https://gerrit.wikimedia.org/r/828649

Mentioned in SAL (#wikimedia-releng) [2022-09-09T17:25:45Z] <Daimona> Applying schema change to the wikishared DB on beta for the CampaignEvents extension (1/2) # T311126

Change 828644 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Create new columns to store local times and timezone

https://gerrit.wikimedia.org/r/828644

Mentioned in SAL (#wikimedia-releng) [2022-09-09T17:46:52Z] <Daimona> Applying schema change to the wikishared DB on beta for the CampaignEvents extension (2/2) # T311126

Change 829014 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Introduce distinction between local and UTC time

https://gerrit.wikimedia.org/r/829014

vaughnwalters subscribed.

AC:
✅ Create the new columns on campaign_events table:

  • event_start_local
  • event_start_utc
  • event_end_local
  • event_end_utc
  • event_timezone

New columns all exist on the betacluster campaign_events table:

MariaDB [wikishared]> DESCRIBE campaign_events;
+------------------------------+---------------------+------+-----+---------+----------------+
| Field                        | Type                | Null | Key | Default | Extra          |
+------------------------------+---------------------+------+-----+---------+----------------+
| event_id                     | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| event_name                   | varbinary(255)      | NO   |     | NULL    |                |
| event_page_namespace         | int(10) unsigned    | NO   |     | NULL    |                |
| event_page_title             | varbinary(255)      | NO   |     | NULL    |                |
| event_page_wiki              | varbinary(64)       | NO   | MUL | NULL    |                |
| event_page_prefixedtext      | varbinary(512)      | NO   |     | NULL    |                |
| event_chat_url               | blob                | NO   |     | NULL    |                |
| event_tracking_tool_id       | int(11)             | YES  |     | NULL    |                |
| event_tracking_tool_event_id | blob                | YES  |     | NULL    |                |
| event_status                 | int(11)             | NO   |     | NULL    |                |
| event_timezone               | varbinary(64)       | NO   | MUL | NULL    |                |
| event_start_local            | binary(14)          | NO   |     | NULL    |                |
| event_start_utc              | binary(14)          | NO   |     | NULL    |                |
| event_end_local              | binary(14)          | NO   |     | NULL    |                |
| event_end_utc                | binary(14)          | NO   |     | NULL    |                |
| event_type                   | varbinary(255)      | NO   |     | NULL    |                |
| event_meeting_type           | int(11)             | NO   |     | NULL    |                |
| event_meeting_url            | blob                | NO   |     | NULL    |                |
| event_meeting_country        | varbinary(255)      | NO   |     | NULL    |                |
| event_meeting_address        | blob                | NO   |     | NULL    |                |
| event_created_at             | binary(14)          | NO   |     | NULL    |                |
| event_last_edit              | binary(14)          | NO   |     | NULL    |                |
| event_deleted_at             | binary(14)          | YES  |     | NULL    |                |
+------------------------------+---------------------+------+-----+---------+----------------+
23 rows in set (0.003 sec)

@Daimona are the following two AC testable on my end yet, and if so what needs tested?

AC:

  • Change the code as needed to save the data on the new columns
  • Change the code as needed to display the right information for the user

AC:

  • Update documentation of the endpoints:
    • Add the timezone to the response of "get details of an event"
    • Note that start and end time are local in "get details of an event" and the 2 endpoints for enabling/editing an event

@Daimona Get details of an event endpoint API doc needs to have timezone added in. GET request example from : https://en.wikipedia.beta.wmflabs.org/w/rest.php/campaignevents/v0/event_registration/118

{
    "id": 118,
    "name": "81",
    "event_page": "Event:81",
    "event_page_wiki": "enwiki",
    "chat_url": "https://testchat.com",
    "status": "open",
    "timezone": "UTC",
    "start_time": "20220824203835",
    "end_time": "20280126203758",
    "online_meeting": true,
    "inperson_meeting": true,
    "meeting_url": "https://thatmeetingurltho.com",
    "meeting_country": "USA",
    "meeting_address": "555 Douglas Ave \nNashville tn 37222"
}

@Daimona are the following two AC testable on my end yet, and if so what needs tested?

AC:

  • Change the code as needed to save the data on the new columns

This is an internal detail that you don't really need to test explicitly, in my opinion.

  • Change the code as needed to display the right information for the user

Yeah, this should be tested. In general, you should make sure that anything time-related still works correctly; behaviour should be the same as before. The following things come to mind (potentially incomplete list):

  • Enable/edit registration (time inputs)
    • Cannot enable registration with start date in the past
    • End date must be after start date
  • View event time on event page and Special:EventDetails
  • View start times on Special:MyEvents, make sure that sorting is correct
  • Cannot register for an event after it has finished
  • "Get details of an event" returns correct info

Note that since we're still using UTC everywhere, I don't expect any bug or surprising behaviour, so a quick round of testing should suffice. The same tests should be repeated, but much more thoroughly, when we will add the ability to specify the event timezone (T315691).

AC:

  • Update documentation of the endpoints:
    • Add the timezone to the response of "get details of an event"
    • Note that start and end time are local in "get details of an event" and the 2 endpoints for enabling/editing an event

@Daimona Get details of an event endpoint API doc needs to have timezone added in. GET request example from : https://en.wikipedia.beta.wmflabs.org/w/rest.php/campaignevents/v0/event_registration/118

Thank you, I've just updated the documentation.

AC:
✅ Change the code as needed to display the right information for the user

Yeah, this should be tested. In general, you should make sure that anything time-related still works correctly; behaviour should be the same as before. The following things come to mind (potentially incomplete list):

  • Enable/edit registration (time inputs)
    • Cannot enable registration with start date in the past
    • End date must be after start date
  • View event time on event page and Special:EventDetails
  • View start times on Special:MyEvents, make sure that sorting is correct
  • Cannot register for an event after it has finished
  • "Get details of an event" returns correct info

Note that since we're still using UTC everywhere, I don't expect any bug or surprising behaviour, so a quick round of testing should suffice. The same tests should be repeated, but much more thoroughly, when we will add the ability to specify the event timezone (T315691).

Testing the following here:
Enable/edit registration (time inputs)

  • Cannot enable registration with start date in the past
    Screen Shot 2022-09-09 at 8.05.32 PM.png (1×1 px, 157 KB)
  • End date must be after start date
    Screen Shot 2022-09-09 at 8.04.41 PM.png (756×1 px, 102 KB)

View event time on

  • event page
    Screen Shot 2022-09-09 at 8.06.57 PM.png (220×1 px, 37 KB)
  • and Special:EventDetails
    Screen Shot 2022-09-09 at 8.07.26 PM.png (548×1 px, 56 KB)

View start times on Special:MyEvents, make sure that sorting is correct

Screen Recording 2022-09-09 at 8.08.27 PM.gif (1×2 px, 1 MB)

Cannot register for an event after it has finished

Screen Shot 2022-09-09 at 8.14.24 PM.png (1×2 px, 280 KB)

"Get details of an event" returns correct info
Screen Shot 2022-09-09 at 8.10.49 PM.png (1×1 px, 129 KB)


Thank you for that clarification @Daimona - all of the testable AC passes and the API docs look good now so I am marking this as done.