Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All raw times should have an absolute time #265

Closed
moveson opened this issue Mar 4, 2020 · 2 comments
Closed

All raw times should have an absolute time #265

moveson opened this issue Mar 4, 2020 · 2 comments
Labels
technical debt Upgrades and refactoring

Comments

@moveson
Copy link
Collaborator

moveson commented Mar 4, 2020

Lack of an absolute time on some raw times is causing a number of minor problems throughout the app. Currently, raw times coming in from OST Remote are coming in as absolute_time with full date and time (with zone) information. Raw times coming from the Live Entry screen have just an entered_time which is military time without date information.

Every raw time should have an absolute time. But we should preserve what is coming in from various clients, so we need to make a few changes.

  1. OST Remote should post times to entered_time (string) instead of absolute_time (datetime)
  2. entered_time should become a required field.
  3. After posting, a worker should convert entered_time to absolute_time, using lap to help if necessary. In a multi-lap event, if we have only a military time and no lap, we should still try to compute an absolute time.
  4. We should have a new entered_lap field, which will contain the data submitted by a client. Then lap will be a purely computed field.

Other required fields stay as is: event_group_id, split_name, bitkey, bib_number, and source.

This will be a major rewrite in some respects. We need to sketch out existing logic and proposed new logic for all this.

@moveson
Copy link
Collaborator Author

moveson commented Aug 17, 2020

This isn't broken per se, but something in the chain is taking a perfectly good entered_time timestamp and replacing it with a military time without any date or timezone information. Looks like it is the same process that sets data_status and lap. Below is output from four Version objects for a single example from a recent event. The unwanted behavior happens in the third step.

irb(main):012:0> versions.each { |version| pp version.attributes }; nil

# Step 1
{"id"=>290813,
 "item_type"=>"RawTime",
 "item_id"=>46667,
 "event"=>"create",
 "whodunnit"=>"701",
 "object"=>nil,
 "created_at"=>Sat, 15 Aug 2020 20:09:52 UTC +00:00,
 "object_changes"=>
  {"id"=>[nil, 46667],
   "event_group_id"=>[nil, 295],
   "split_name"=>[nil, "Towers 3"],
   "bitkey"=>[nil, 1],
   "bib_number"=>[nil, "611"],
   "entered_time"=>[nil, "2020-08-15 14:09:17-6:00"],
   "source"=>[nil, "ost-remote-1831D2F1-7A01-4A09-9A13-8CB78421F15D"],
   "created_by"=>[nil, 701],
   "updated_by"=>[nil, 701],
   "created_at"=>[nil, "2020-08-15T20:09:52.876Z"],
   "updated_at"=>[nil, "2020-08-15T20:09:52.876Z"],
   "parameterized_split_name"=>[nil, "towers-3"],
   "sortable_bib_number"=>[nil, 611],
   "matchable_bib_number"=>[nil, 611]}}

# Step 2
{"id"=>290814,
 "item_type"=>"RawTime",
 "item_id"=>46667,
 "event"=>"update",
 "whodunnit"=>nil,
 "object"=>
  {"event_group_id"=>295,
   "entered_lap"=>nil,
   "lap"=>1,
   "absolute_time"=>nil,
   "entered_time"=>"2020-08-15 14:09:17-6:00",
   "id"=>46667,
   "created_by"=>701,
   "split_name"=>"Towers 3",
   "parameterized_split_name"=>"towers-3",
   "bib_number"=>"611",
   "sortable_bib_number"=>611,
   "matchable_bib_number"=>611,
   "data_status"=>nil,
   "bitkey"=>1,
   "source"=>"ost-remote-1831D2F1-7A01-4A09-9A13-8CB78421F15D",
   "split_time_id"=>nil,
   "with_pacer"=>false,
   "stopped_here"=>false,
   "pulled_by"=>nil,
   "pulled_at"=>nil,
   "updated_by"=>701,
   "created_at"=>"2020-08-15T20:09:52.876Z",
   "updated_at"=>"2020-08-15T20:09:52.876Z",
   "remarks"=>nil,
   "disassociated_from_effort"=>nil,
   "effort_id"=>46925,
   "effort_last_name"=>"Hanback",
   "event_id"=>301,
   "split_id"=>352,
   "split_time_exists"=>nil},
 "created_at"=>Sat, 15 Aug 2020 20:09:52 UTC +00:00,
 "object_changes"=>
  {"lap"=>[nil, 1],
   "absolute_time"=>[nil, "2020-08-15T20:09:17.000Z"],
   "updated_at"=>["2020-08-15T20:09:52.876Z", "2020-08-15T20:09:52.923Z"]}}

# Step 3
{"id"=>290815,
 "item_type"=>"RawTime",
 "item_id"=>46667,
 "event"=>"update",
 "whodunnit"=>nil,
 "object"=>
  {"split_time_id"=>nil,
   "id"=>46667,
   "event_group_id"=>295,
   "split_name"=>"Towers 3",
   "bitkey"=>1,
   "bib_number"=>"611",
   "absolute_time"=>"2020-08-15T20:09:17.000Z",
   "entered_time"=>"2020-08-15 14:09:17-6:00",
   "with_pacer"=>false,
   "stopped_here"=>false,
   "source"=>"ost-remote-1831D2F1-7A01-4A09-9A13-8CB78421F15D",
   "pulled_by"=>nil,
   "pulled_at"=>nil,
   "created_by"=>701,
   "updated_by"=>701,
   "created_at"=>"2020-08-15T20:09:52.876Z",
   "updated_at"=>"2020-08-15T20:09:52.923Z",
   "parameterized_split_name"=>"towers-3",
   "remarks"=>nil,
   "sortable_bib_number"=>611,
   "data_status"=>nil,
   "matchable_bib_number"=>611,
   "disassociated_from_effort"=>nil,
   "entered_lap"=>nil,
   "lap"=>1,
   "split_time_exists"=>false,
   "effort_id"=>46925,
   "effort_last_name"=>"Hanback",
   "event_id"=>301,
   "split_id"=>352},
 "created_at"=>Sat, 15 Aug 2020 20:09:52 UTC +00:00,
 "object_changes"=>
  {"entered_time"=>["2020-08-15 14:09:17-6:00", "14:09:17"],
   "updated_at"=>["2020-08-15T20:09:52.923Z", "2020-08-15T20:09:52.995Z"],
   "data_status"=>[nil, "good"],
   "lap"=>[nil, 1],
   "split_time_exists"=>[nil, false]}}

# Step 4
{"id"=>290817,
 "item_type"=>"RawTime",
 "item_id"=>46667,
 "event"=>"update",
 "whodunnit"=>nil,
 "object"=>
  {"split_time_id"=>nil,
   "id"=>46667,
   "event_group_id"=>295,
   "split_name"=>"Towers 3",
   "bitkey"=>1,
   "bib_number"=>"611",
   "absolute_time"=>"2020-08-15T20:09:17.000Z",
   "entered_time"=>"14:09:17",
   "with_pacer"=>false,
   "stopped_here"=>false,
   "source"=>"ost-remote-1831D2F1-7A01-4A09-9A13-8CB78421F15D",
   "pulled_by"=>nil,
   "pulled_at"=>nil,
   "created_by"=>701,
   "updated_by"=>701,
   "created_at"=>"2020-08-15T20:09:52.876Z",
   "updated_at"=>"2020-08-15T20:09:52.995Z",
   "parameterized_split_name"=>"towers-3",
   "remarks"=>nil,
   "sortable_bib_number"=>611,
   "data_status"=>"good",
   "matchable_bib_number"=>611,
   "disassociated_from_effort"=>nil,
   "entered_lap"=>nil,
   "lap"=>1,
   "split_time_exists"=>false,
   "effort_id"=>46925,
   "effort_last_name"=>"Hanback",
   "event_id"=>301,
   "split_id"=>352},
 "created_at"=>Sat, 15 Aug 2020 20:09:53 UTC +00:00,
 "object_changes"=>
  {"split_time_id"=>[nil, 338875],
   "updated_at"=>["2020-08-15T20:09:52.995Z", "2020-08-15T20:09:53.030Z"]}}

Tracking this separately in #401

@moveson
Copy link
Collaborator Author

moveson commented Jun 19, 2023

This is done.

@moveson moveson closed this as completed Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical debt Upgrades and refactoring
Projects
None yet
Development

No branches or pull requests

1 participant