Skip to content

Commit

Permalink
Merge pull request #3396 from ProjectSidewalk/3375-launch-date-API
Browse files Browse the repository at this point in the history
Added launch date to overallStats API call
  • Loading branch information
misaugstad authored Oct 23, 2023
2 parents 7383147 + e328eeb commit 0987a50
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/controllers/ProjectSidewalkAPIController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ class ProjectSidewalkAPIController @Inject()(implicit val env: Environment[User,
val writer = new java.io.PrintStream(sidewalkStatsFile)

val stats: ProjectSidewalkStats = LabelTable.getOverallStatsForAPI(filterLowQuality)
writer.println(s"Launch Date, ${stats.launchDate}")
writer.println(s"KM Explored,${stats.kmExplored}")
writer.println(s"KM Explored Without Overlap,${stats.kmExploreNoOverlap}")
writer.println(s"Total User Count,${stats.nUsers}")
Expand All @@ -862,6 +863,7 @@ 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.close()
Future.successful(Ok.sendFile(content = sidewalkStatsFile, onClose = () => sidewalkStatsFile.delete()))
} else { // In JSON format.
Expand Down
1 change: 1 addition & 0 deletions app/formats/json/APIFormats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ object APIFormats {

def projectSidewalkStatsToJson(stats: ProjectSidewalkStats): JsObject = {
Json.obj(
"launch_date" -> stats.launchDate,
"km_explored" -> stats.kmExplored,
"km_explored_no_overlap" -> stats.kmExploreNoOverlap,
"user_counts" -> Json.obj(
Expand Down
11 changes: 8 additions & 3 deletions app/models/label/LabelTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ case class LabelLocationWithSeverity(labelId: Int, auditTaskId: Int, gsvPanorama

case class LabelSeverityStats(n: Int, nWithSeverity: Int, severityMean: Option[Float], severitySD: Option[Float])
case class LabelAccuracy(n: Int, nAgree: Int, nDisagree: Int, accuracy: Option[Float])
case class ProjectSidewalkStats(kmExplored: Float, kmExploreNoOverlap: Float, nUsers: Int, nExplorers: Int,
case class ProjectSidewalkStats(launchDate: String, kmExplored: Float, kmExploreNoOverlap: Float, nUsers: Int, nExplorers: Int,
nValidators: Int, nRegistered: Int, nAnon: Int, nTurker: Int, nResearcher: Int,
nLabels: Int, severityByLabelType: Map[String, LabelSeverityStats], nValidations: Int,
accuracyByLabelType: Map[String, LabelAccuracy])
Expand Down Expand Up @@ -228,7 +228,8 @@ object LabelTable {
)

implicit val projectSidewalkStatsConverter = GetResult[ProjectSidewalkStats](r => ProjectSidewalkStats(
r.nextFloat, r.nextFloat, r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextInt,
r.nextString, r.nextFloat, r.nextFloat, r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextInt,
r.nextInt,
Map(
"CurbRamp" -> LabelSeverityStats(r.nextInt, r.nextInt, r.nextFloatOption, r.nextFloatOption),
"NoCurbRamp" -> LabelSeverityStats(r.nextInt, r.nextInt, r.nextFloatOption, r.nextFloatOption),
Expand Down Expand Up @@ -1100,8 +1101,12 @@ object LabelTable {
if (filterLowQuality) "user_stat.high_quality"
else "NOT user_stat.excluded"

val cityId: String = Play.configuration.getString("city-id").get
val launchDate: String = Play.configuration.getString(s"city-params.launch-date.$cityId").get

val overallStatsQuery = Q.queryNA[ProjectSidewalkStats](
s"""SELECT km_audited.km_audited AS km_audited,
s"""SELECT '$launchDate' AS launch_date,
| km_audited.km_audited AS km_audited,
| km_audited_no_overlap.km_audited_no_overlap AS km_audited_no_overlap,
| users.total_users,
| users.audit_users,
Expand Down
23 changes: 23 additions & 0 deletions conf/cityparams.conf
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,29 @@ city-params {
teaneck-nj = "public"
walla-walla-wa = "private"
}
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"
walla-walla-wa = "2023-10-05"
}
skyline-img = {
newberg-or = "skyline1.png"
washington-dc = "skyline-dc.png"
Expand Down

0 comments on commit 0987a50

Please sign in to comment.