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

JFK umass mezzanine refactor #661

Merged
merged 10 commits into from
Jul 26, 2023
Merged

JFK umass mezzanine refactor #661

merged 10 commits into from
Jul 26, 2023

Conversation

PaulJKim
Copy link
Collaborator

Summary of changes

The JFK/UMass Mezzanine case where the top line (SB) is on headways while the bottom line is on a prediction was not handled in the previous version and would try to page the prediction on the top line while showing paging headways on the bottom line. This would surpass the character limit for the top line.

This PR takes advantage of some of the new code added for the Early AM Predictions suppression to handle this case.

@PaulJKim PaulJKim mentioned this pull request Jul 20, 2023
7 tasks
@github-actions
Copy link

Coverage of commit c2bf89b

Summary coverage rate:
  lines......: 76.4% (1770 of 2316 lines)
  functions..: 76.2% (486 of 638 functions)
  branches...: no data found

Files changed coverage rate:
                                                             |Lines       |Functions  |Branches    
  Filename                                                   |Rate     Num|Rate    Num|Rate     Num
  =================================================================================================
  lib/content/audio/first_train_scheduled.ex                 |75.0%      8|66.7%     6|    -      0
  lib/content/message/custom.ex                              | 100%     12| 100%     6|    -      0
  lib/content/message/early_am/destination_scheduled_time.ex | 0.0%      2| 0.0%     4|    -      0
  lib/content/message/early_am/destination_train.ex          | 0.0%      2| 0.0%     4|    -      0
  lib/content/message/early_am/scheduled_time.ex             | 0.0%      2| 0.0%     4|    -      0
  lib/content/message/generic_paging.ex                      |50.0%      2|50.0%     4|    -      0
  lib/content/message/platform_prediction_bottom.ex          |33.3%      3|50.0%     4|    -      0
  lib/content/utilities.ex                                   |38.5%     65|62.5%     8|    -      0
  lib/pa_ess/utilities.ex                                    |72.3%    195|96.2%    26|    -      0
  lib/signs/utilities/audio.ex                               |87.7%     73| 100%     7|    -      0
  lib/signs/utilities/messages.ex                            |56.4%     55|70.0%    10|    -      0

Download coverage report

@github-actions
Copy link

Coverage of commit cd5c903

Summary coverage rate:
  lines......: 76.5% (1786 of 2335 lines)
  functions..: 76.4% (491 of 643 functions)
  branches...: no data found

Files changed coverage rate:
                                                             |Lines       |Functions  |Branches    
  Filename                                                   |Rate     Num|Rate    Num|Rate     Num
  =================================================================================================
  lib/signs/utilities/messages.ex                            |56.4%     55|70.0%    10|    -      0

Download coverage report

Copy link
Collaborator

@panentheos panentheos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments, otherwise looks good.

Comment on lines +31 to +52
case Signs.Utilities.Predictions.get_messages(predictions, sign) do
{%Content.Message.Empty{}, %Content.Message.Empty{}} ->
get_headway_or_alert_messages(sign, current_time, alert_status)

{top_message, %Content.Message.Empty{}} ->
{top_message,
get_paging_headway_or_alert_messages(sign, current_time, alert_status, :bottom)}

{%Content.Message.Empty{}, bottom_message} ->
if match?(
%Content.Message.Predictions{station_code: "RJFK", zone: "m"},
bottom_message
) do
jfk_umass_headway_paging(bottom_message, sign, current_time, alert_status)
else
{get_paging_headway_or_alert_messages(sign, current_time, alert_status, :top),
bottom_message}
end

messages ->
messages
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking out loud: This logic looks correct, and I think it's in a good state for now, but it's definitely hinting at a different way of framing the problem. E.g. "for each route, generate a prediction/headway/alert message, then lay them out so they fit." (This is more or less what I mentioned before, just reiterating it in context)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed although, I don't think I have as clear of an idea how that different approach would look in practice. I'd like to hear in more detail about how you're envisioning things! Let's chat soon about it

Comment on lines +55 to +57
flip? = flip?(messages)

if flip?,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
flip? = flip?(messages)
if flip?,
if flip?(messages),

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may leave this one for now in as I re-use the flip? variable in a couple more places in the subsequent PR

{%Content.Message.GenericPaging{
messages: [
# Make zone nil in order to prevent the usual paging platform message
%{prediction | zone: nil},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this prediction message nested inside the generic paging message, the countup? logic won't trigger as usual. We need to expand that logic if we want it to keep working for this case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah great catch, thank you!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@panentheos just pushed some changes to expand the countup logic. Mind taking another quick pass? 🙏

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be a larger issue here, if I'm reading this correctly: In the JFK special case, there's an implicit flip happening; the non-empty prediction comes from the bottom, but in the full-page rendering is embedded on top. Because the caller of same_content? always compares top-to-top and bottom-to-bottom, we have no way of matching up the corresponding predictions in that case. The upshot is that as we transition in/out of the special case, we might let a count-up slip through. Does that sound right?

I think addressing that would require a substantial refactor of the same_content? calculation, which seems overly risky right now. My inclination is to document this issue with a comment, and address it in a future change. Thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh hm yes, I think that's correct. We can't match up the predictions when we're transitioning between the two formats and would potentially miss a count-up.

Alternatively, I think we could get around having to do a more substantial refactor by mapping the PlatformPredictionBottom struct to a regular Prediction struct before calling countup? again. I think it should be a safe assumption that the destinations are the same (:alewife) since this is such a specific case, or we could also just pass along the destination when we create the PlatformPredictionBottom struct. We already pass along the minutes to the bottom so we would have all the pieces handy for the countup logic to do its thing.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess that works, as long as we call out with a comment that it's tailored for the special case.

@github-actions
Copy link

Coverage of commit 9bd9b14

Summary coverage rate:
  lines......: 76.4% (1786 of 2338 lines)
  functions..: 76.4% (491 of 643 functions)
  branches...: no data found

Files changed coverage rate:
                                                             |Lines       |Functions  |Branches    
  Filename                                                   |Rate     Num|Rate    Num|Rate     Num
  =================================================================================================
  lib/signs/utilities/messages.ex                            |53.4%     58|70.0%    10|    -      0

Download coverage report

@github-actions
Copy link

Coverage of commit 94c5f4c

Summary coverage rate:
  lines......: 76.4% (1786 of 2338 lines)
  functions..: 76.4% (491 of 643 functions)
  branches...: no data found

Files changed coverage rate:
                                                             |Lines       |Functions  |Branches    
  Filename                                                   |Rate     Num|Rate    Num|Rate     Num
  =================================================================================================
  lib/content/message/platform_prediction_bottom.ex          |33.3%      3|50.0%     4|    -      0
  lib/signs/utilities/messages.ex                            |53.4%     58|70.0%    10|    -      0

Download coverage report

@PaulJKim PaulJKim merged commit be77d8c into main Jul 26, 2023
1 check passed
@PaulJKim PaulJKim deleted the pk/jfk-umass-mezzanine-refactor branch July 26, 2023 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants