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

completed config table for each city's database. #3281

Closed
wants to merge 36 commits into from
Closed

Conversation

dylanbun
Copy link
Collaborator

@dylanbun dylanbun commented Jun 29, 2023

Resolves #2772

Implemented a table that holds all of the relevant columns for a respective city's configuration such as latitude, offset hour, tutorial street edge id to easily update them. Had to include some funny SQL in 194.sql to have config be a one row table.

NOTE: Before approving, there is one comment with "- Dylan" to confirm if this should use ConfigTable or not.

Testing instructions
  1. open choice for viewing table data (pgadmin >)
  2. go into the config table and confirm if the data matches up. can also confirm this by looking at 194.sql.
Things to check before submitting the PR
  • I've written a descriptive PR title.

Copy link
Member

@misaugstad misaugstad left a comment

Choose a reason for hiding this comment

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

Unfortunately it looks like you 600 line PR is only 600 line because your IDE auto reformatted a bunch of code that you should try to undo ;) comments throughout the code!

app/models/label/LabelTable.scala Outdated Show resolved Hide resolved
@@ -867,4 +867,4 @@ class ProjectSidewalkAPIController @Inject()(implicit val env: Environment[User,
Future.successful(Ok(APIFormats.projectSidewalkStatsToJson(LabelTable.getOverallStatsForAPI(filterLowQuality))))
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Looks like by default it's also removing new lines at the ends of files, which has happened to a bunch of files in the PR, which is the opposite of what's in the style guide! So definitely make sure to add the newlines back to the files.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At least for this file compared to the one in the develop branch, they appear the same to me. Is there something I am not seeing for this file?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure I totally understand. The only info I'm working off of is what I see in the "Files changed" tab. If you want it to be identical to develop, you could legit just download the file from Github and paste it in there 🤷

app/models/attribute/ConfigTable.scala Show resolved Hide resolved
val regionLat1: Double = ConfigTable.getRegionLatOne
val regionLng1: Double = ConfigTable.getRegionLngOne
val regionLat2: Double = ConfigTable.getRegionLatTwo
val regionLng2: Double = ConfigTable.getRegionLngTwo

Future.successful(Ok(Json.obj(
Copy link
Member

Choose a reason for hiding this comment

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

Building on the comment above, you can add a toJSON function to the case class that will return a JSON object that looks like the ones below so that you can just call that function instead of building the JSON object for each of them.

import play.api.Play.current
import scala.slick.lifted.ForeignKeyQuery

case class ConfigApi(apiAttributeCenterLat: Double, apiAttributeCenterLng: Double,
Copy link
Member

Choose a reason for hiding this comment

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

Since it's useful to add a MapParams class to simplify other code, it might make sense to replace this big ConfigAPI class with that one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Kinda agree? If you mean just re-naming ConfigAPI to MapParams then that works! However, adding additional parameters would be interesting since ConfigAPI already has 21 parameters and if I recall correctly there is a 22 parameter limit.

Copy link
Member

Choose a reason for hiding this comment

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

I'm suggesting removing the ConfigApi class, and instead adding in a MapParams class that has only 7 (I think it was 7?) fields, but the Config class would contain 3-4 of them instead of just the one ConfigAPI class.

Copy link
Member

Choose a reason for hiding this comment

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

It'd be something like

case class Config(
    openStatus: String, mapathonEventLink: Option[String], overallMapParams: MapParams,
    tutorialStreetEdgeID: Int, offsetHours: Int, excludedTags: String,
    apiAttributeParams: MapParams, apiStreetParams: MapParams, apiRegionParams: MapParams
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good to me, will be pinging you on Slack about this later then :)

app/models/attribute/ConfigTable.scala Outdated Show resolved Hide resolved
app/models/attribute/ConfigTable.scala Outdated Show resolved Hide resolved
conf/evolutions/default/194.sql Outdated Show resolved Hide resolved
@dylanbun
Copy link
Collaborator Author

@misaugstad review this when you have a chance! Will make a ticket to make the code cleaner for a future task, but would like to have this ready to go.

@misaugstad
Copy link
Member

Something is broken with Github so I'm going to close this PR and try to make a new one...

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.

Mark tutorial street_edge_id in database
2 participants