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

Added launch date to overallStats API call #3396

Merged
merged 4 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/controllers/ProjectSidewalkAPIController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import models.daos.slick.DBTableDefinitions.{DBUser, UserTable}
import models.label.{LabelLocation, LabelTable, ProjectSidewalkStats}
import models.street.{StreetEdge, StreetEdgeInfo, StreetEdgeTable}
import models.user.{User, UserStatTable, WebpageActivity, WebpageActivityTable}
import play.api.Play
import play.api.Play.current
import play.api.libs.json._
import play.api.libs.json.Json._
Expand Down Expand Up @@ -833,6 +834,8 @@ class ProjectSidewalkAPIController @Inject()(implicit val env: Environment[User,

def getOverallSidewalkStats(filterLowQuality: Boolean, filetype: Option[String]) = UserAwareAction.async { implicit request =>
apiLogging(request.remoteAddress, request.identity, request.toString)
val cityId = Play.configuration.getString("city-id").get
val launchDate = Play.configuration.getString(s"city-params.launch-date.$cityId").get
// In CSV format.
if (filetype.isDefined && filetype.get == "csv") {
val sidewalkStatsFile = new java.io.File("project_sidewalk_stats.csv")
Expand Down Expand Up @@ -862,10 +865,14 @@ class ProjectSidewalkAPIController @Inject()(implicit val env: Environment[User,
writer.println(s"$labType Disagreed Count,${accStats.nDisagree}")
writer.println(s"$labType Accuracy,${accStats.accuracy.map(_.toString).getOrElse("NA")}")
}

writer.println(s"Launch Date, ${launchDate}")
writer.close()
Future.successful(Ok.sendFile(content = sidewalkStatsFile, onClose = () => sidewalkStatsFile.delete()))
} else { // In JSON format.
Future.successful(Ok(APIFormats.projectSidewalkStatsToJson(LabelTable.getOverallStatsForAPI(filterLowQuality))))
Future.successful(Ok(APIFormats.projectSidewalkStatsToJson(LabelTable.getOverallStatsForAPI(filterLowQuality)) +
misaugstad marked this conversation as resolved.
Show resolved Hide resolved
("launch_date" -> Json.toJson(launchDate))
))
}
}
}
22 changes: 22 additions & 0 deletions conf/cityparams.conf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,28 @@ city-params {
burnaby = "private"
teaneck-nj = "public"
}
launch-date {
newberg-or = "2019-01-31"
washington-dc = "2015-10-17"
seattle-wa = "2019-03-12"
columbus-oh = "2019-11-12"
cdmx = "2020-01-09"
spgg = "2020-05-30"
pittsburgh-pa = "2020-07-30"
chicago-il = "2021-09-03"
amsterdam = "2022-03-17"
la-piedad = "2022-03-17"
oradell-nj = "2022-03-17"
validation-study = "2022-05-10"
zurich = "2022-11-08"
taipei = "2023-01-24"
new-taipei-tw = "2023-08-06"
keelung-tw = "2023-08-10"
auckland = "2023-02-14"
cuenca = "2023-04-02"
burnaby = "2023-08-09"
teaneck-nj = "2023-08-24"
misaugstad marked this conversation as resolved.
Show resolved Hide resolved
}
skyline-img = {
newberg-or = "skyline1.png"
washington-dc = "skyline-dc.png"
Expand Down