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

🍎🚫💰 Surface prediction 'uncertainty' values through v3 API #698

Merged
merged 6 commits into from
Dec 21, 2023

Conversation

bfauble
Copy link
Contributor

@bfauble bfauble commented Nov 3, 2023

Summary of changes

Asana Ticket: 🍎🚫💰 Surface prediction 'uncertainty' values through v3 API

example response:

{
  "data": [
    {
      "attributes": {
        "arrival_time": null,
        "arrival_uncertainty": null,
        "departure_time": "2023-11-03T13:13:00-04:00",
        "departure_uncertainty": null,
        "direction_id": 1,
        "schedule_relationship": null,
        "status": null,
        "stop_sequence": 50
      },
      "id": "prediction-59095632-70094-50",
      "relationships": {
        "route": {
          "data": {
            "id": "Red",
            "type": "route"
          }
        },
        "stop": {
          "data": {
            "id": "70094",
            "type": "stop"
          }
        },
        "trip": {
          "data": {
            "id": "59095632",
            "type": "trip"
          }
        },
        "vehicle": {
          "data": {
            "id": "R-54795DFB",
            "type": "vehicle"
          }
        }
      },
      "type": "prediction"
    },
    ...

@bfauble bfauble requested review from a team, meagharty and nlwstein November 3, 2023 17:11
Copy link

github-actions bot commented Nov 3, 2023

Coverage of commit 23a253f

Summary coverage rate:
  lines......: 89.2% (4135 of 4637 lines)
  functions..: 70.9% (2232 of 3150 functions)
  branches...: no data found

Files changed coverage rate:
                                                                        |Lines       |Functions  |Branches    
  Filename                                                              |Rate     Num|Rate    Num|Rate     Num
  ============================================================================================================
  apps/api_web/lib/api_web/controllers/prediction_controller.ex         |96.0%     75|95.5%    22|    -      0
  apps/api_web/lib/api_web/views/prediction_view.ex                     |94.9%     59|52.9%    51|    -      0
  apps/model/lib/model/prediction.ex                                    | 0.0%      2| 0.0%    10|    -      0
  apps/parse/lib/parse/trip_updates.ex                                  |70.0%     40| 100%     9|    -      0

Download coverage report

@paulswartz
Copy link
Member

question: is there a reason to ship this before we're providing the data in Concentrate?

@bfauble
Copy link
Contributor Author

bfauble commented Nov 3, 2023

question: is there a reason to ship this before we're providing the data in Concentrate?

No particular reason. The concentrate portion is set to be done this sprint and can wait until that is out before merging/deploying this.

Copy link
Contributor

@nlwstein nlwstein left a comment

Choose a reason for hiding this comment

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

A couple of random thoughts but overall this looks good! 🚀

@@ -54,6 +56,12 @@ defmodule Parse.TripUpdates do
nil
end

defp parse_uncertainty(%{uncertainty: uncertainty}) when is_integer(uncertainty) do
Copy link
Contributor

Choose a reason for hiding this comment

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

Since your documentation (nice!) only allows three values, would it make sense to only allow those three values through? I think you can use a guard like when is_integer(uncertainty) and uncertainty in [60, 120, 360] but I haven't tested it.

Copy link
Member

Choose a reason for hiding this comment

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

Does this incorporate the uncertainty values that Swiftly uses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could be mistaken, but I think those values are converted into the 60, 120, 360 versions before they make it here. I'll look into that to verify.

Copy link
Contributor Author

@bfauble bfauble Nov 7, 2023

Choose a reason for hiding this comment

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

Looks like these values are only rail, the swiftly values, which are different, cover bus/CR. Will update docs/types to address.

@@ -261,6 +261,34 @@ defmodule ApiWeb.PredictionController do
example: "2017-08-14T15:38:58-04:00"
)

arrival_uncertainty(
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this get sucked into Swagger? I can't remember, but if it doesn't, might be worth outputting this to the docs wherever this field shows up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, these show up in the models section at the bottom of the swagger docs

@bfauble bfauble assigned bfauble and unassigned bfauble Nov 8, 2023
@bfauble
Copy link
Contributor Author

bfauble commented Nov 8, 2023

@nlwstein @paulswartz moved swagger docs into separate PR to include other non-rev documentation here: #700

@bklebe bklebe added the do not merge Do not merge label Nov 22, 2023
Copy link

github-actions bot commented Dec 5, 2023

Coverage of commit cb8a2c5

Summary coverage rate:
  lines......: 89.2% (4140 of 4642 lines)
  functions..: 70.9% (2238 of 3155 functions)
  branches...: no data found

Files changed coverage rate:
                                                                        |Lines       |Functions  |Branches    
  Filename                                                              |Rate     Num|Rate    Num|Rate     Num
  ============================================================================================================
  apps/api_web/lib/api_web/views/prediction_view.ex                     |94.9%     59|52.9%    51|    -      0
  apps/model/lib/model/prediction.ex                                    | 0.0%      2| 0.0%    10|    -      0
  apps/parse/lib/parse/trip_updates.ex                                  |70.0%     40| 100%     9|    -      0

Download coverage report

Copy link

Coverage of commit 02b96cb

Summary coverage rate:
  lines......: 89.1% (4138 of 4642 lines)
  functions..: 70.9% (2238 of 3155 functions)
  branches...: no data found

Files changed coverage rate:
                                                                        |Lines       |Functions  |Branches    
  Filename                                                              |Rate     Num|Rate    Num|Rate     Num
  ============================================================================================================
  apps/api_web/lib/api_web/views/prediction_view.ex                     |94.9%     59|52.9%    51|    -      0
  apps/model/lib/model/prediction.ex                                    | 0.0%      2| 0.0%    10|    -      0
  apps/parse/lib/parse/trip_updates.ex                                  |70.0%     40| 100%     9|    -      0

Download coverage report

Copy link

Coverage of commit 688ae59

Summary coverage rate:
  lines......: 89.2% (4175 of 4680 lines)
  functions..: 71.0% (2251 of 3169 functions)
  branches...: no data found

Files changed coverage rate:
                                                                        |Lines       |Functions  |Branches    
  Filename                                                              |Rate     Num|Rate    Num|Rate     Num
  ============================================================================================================
  apps/api_web/lib/api_web/views/prediction_view.ex                     |95.0%     60|52.8%    53|    -      0
  apps/model/lib/model/prediction.ex                                    | 0.0%      2| 0.0%    10|    -      0
  apps/parse/lib/parse/trip_updates.ex                                  |72.1%     43| 100%    10|    -      0

Download coverage report

@bfauble bfauble merged commit d206680 into master Dec 21, 2023
6 checks passed
@bfauble bfauble deleted the bf-publish-uncertainty-values branch December 21, 2023 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Do not merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants