Skip to content

Commit

Permalink
Merge pull request #2132 from ProjectSidewalk/develop
Browse files Browse the repository at this point in the history
v6.8.4
  • Loading branch information
misaugstad authored Jun 10, 2020
2 parents db11c8f + 8b9ab93 commit 7678526
Show file tree
Hide file tree
Showing 45 changed files with 529 additions and 285 deletions.
11 changes: 6 additions & 5 deletions app/controllers/ValidationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ValidationController @Inject() (implicit val env: Environment[User, Sessio
if (validationData._4.missionType != "validation") {
Future.successful(Redirect("/audit"))
} else {
Future.successful(Ok(views.html.validation("Project Sidewalk - Validate", Some(user), validationData._1, validationData._2, validationData._3, validationData._4.numComplete, validationData._5)))
Future.successful(Ok(views.html.validation("Project Sidewalk - Validate", Some(user), validationData._1, validationData._2, validationData._3, validationData._4.numComplete, validationData._5, validationData._6)))
}
case None =>
Future.successful(Redirect(s"/anonSignUp?url=/validate"));
Expand Down Expand Up @@ -109,9 +109,9 @@ class ValidationController @Inject() (implicit val env: Environment[User, Sessio

/**
* Get the data needed by the /validate or /rapidValidate endpoints.
* @return (mission, labelList, missionProgress, missionSetProgress, hasNextMission)
* @return (mission, labelList, missionProgress, missionSetProgress, hasNextMission, completedValidations)
*/
def getDataForValidationPages(user: User, ipAddress: String, labelCount: Int, validationTypeStr: String, visitTypeStr: String): (Option[JsObject], Option[JsValue], Option[JsObject], MissionSetProgress, Boolean) = {
def getDataForValidationPages(user: User, ipAddress: String, labelCount: Int, validationTypeStr: String, visitTypeStr: String): (Option[JsObject], Option[JsValue], Option[JsObject], MissionSetProgress, Boolean, Int) = {
val timestamp: Timestamp = new Timestamp(Instant.now.toEpochMilli)

WebpageActivityTable.save(WebpageActivity(0, user.userId.toString, ipAddress, visitTypeStr, timestamp))
Expand All @@ -123,6 +123,7 @@ class ValidationController @Inject() (implicit val env: Environment[User, Sessio
val possibleLabTypeIds: List[Int] = LabelTable.retrievePossibleLabelTypeIds(user.userId, labelCount, None)
val hasWork: Boolean = possibleLabTypeIds.nonEmpty

val completedValidations: Int = MissionTable.countCompletedValidationsByUserID(user.userId)
// Checks if there are still labels in the database for the user to validate.
if (hasWork && missionSetProgress.missionType == "validation") {
// possibleLabTypeIds can contain [1, 2, 3, 4, 7]. Select ids 1, 2, 3, 4 if possible, o/w choose 7.
Expand All @@ -138,11 +139,11 @@ class ValidationController @Inject() (implicit val env: Environment[User, Sessio
val missionJsObject: JsObject = mission.toJSON
val progressJsObject: JsObject = LabelValidationTable.getValidationProgress(mission.missionId)

return (Some(missionJsObject), Some(labelList), Some(progressJsObject), missionSetProgress, true)
return (Some(missionJsObject), Some(labelList), Some(progressJsObject), missionSetProgress, true, completedValidations)
} else {
// TODO When fixing the mission sequence infrastructure (#1916), this should update that table since there are
// no validation missions that can be done.
return (None, None, None, missionSetProgress, false)
return (None, None, None, missionSetProgress, false, completedValidations)
}
}

Expand Down
15 changes: 15 additions & 0 deletions app/models/mission/MissionTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ object MissionTable {
})


/**
* Count the total number of labels the user has validated.
*
* @param userId
* @return the total number of labels the user has validated.
*/
def countCompletedValidationsByUserID(userId: UUID): Int = db.withSession { implicit session =>
(for {
_missionType <- missionTypes
_mission <- missions if _missionType.missionTypeId === _mission.missionTypeId
if _missionType.missionType === "validation" && _mission.userId === userId.toString
} yield _mission.labelsProgress).list.flatten.sum
}


/**
* Count the number of missions completed by a user.
*
Expand Down
2 changes: 1 addition & 1 deletion app/views/audit.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ <h3>@Messages("audit.mission.complete.labels.title")</h3>
<td id="modal-mission-complete-curb-ramp-count" class="col-right"></td>
</tr>
<tr>
<th>@Messages("mission.ramp")</th>
<th>@Messages("missing.ramp")</th>
<td id="modal-mission-complete-no-curb-ramp-count" class="col-right"></td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion app/views/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<br><br>
<span class="header-text">@Messages("landing.also.in")</span>
@for((cityName, cityURL) <- otherCityURLs.filter(_._1 != "San Pedro Garza García, MX-NLE")) {
<a class="exploremaplink" href="@{cityURL + "/audit"}">@cityName</a> &nbsp;
<a id="@cityName" class="otherCityLink" href="@{cityURL + "/audit"}">@cityName</a> &nbsp;
}
<br>
@if(mapathonLink.isDefined) {
Expand Down
8 changes: 5 additions & 3 deletions app/views/mobileValidate.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
@import models.amt.AMTAssignmentTable
@import play.api.libs.json.Json
@import play.api.libs.json.JsValue
@import play.api.Play
@import play.api.Play.current
@import views.html.bootstrap._

@(title: String, user: Option[User] = None, mission: Option[JsValue], labelList: Option[JsValue], progress: Option[JsValue], missionSetProgress: Int, hasNextMission: Boolean)(implicit lang: Lang)
Expand Down Expand Up @@ -61,7 +63,7 @@
<div id="modal-mission-holder">
<div id="modal-mission-background" class="modal-background"></div>
<div id="modal-mission-foreground" class="modal-foreground">
<img src='@routes.Assets.at("javascripts/SVValidate/img/logo.png")' id="ps-logo-mission"></img>
<img src='@routes.Assets.at("assets/" + Play.configuration.getString("city-id").get + "/sidewalk-logo.png")' id="ps-logo-mission"></img>
<h1 id="modal-mission-header" class="text-center"></h1>
<div id="modal-mission-instruction"></div>
<button class="button" id="modal-mission-close-button">OK</button>
Expand Down Expand Up @@ -109,7 +111,7 @@ <h1 class="status-holder-header-2" id="label-type-counterexample"></h1>
<div id="modal-mission-complete-holder">
<div id="modal-mission-complete-background" class="modal-background"></div>
<div id="modal-mission-complete-foreground" class="modal-foreground">
<img src='@routes.Assets.at("javascripts/SVValidate/img/logo.png")' id="ps-logo-mission-complete"></img>
<img src='@routes.Assets.at("assets/" + Play.configuration.getString("city-id").get + "/sidewalk-logo.png")' id="ps-logo-mission-complete"></img>
<h1 class="normal" id="modal-mission-complete-title"></h1>
<p><div id="modal-mission-complete-message"></div></p>
<div id="modal-mission-complete-table">
Expand Down Expand Up @@ -138,7 +140,7 @@ <h3>@Messages("validate.mission.complete.category")</h3>
<div id="modal-landscape-holder">
<div id="modal-landscape-background" class="modal-background"></div>
<div id="modal-landscape-foreground" class="modal-foreground">
<img src='@routes.Assets.at("javascripts/SVValidate/img/logo.png")' id="ps-logo-landscape"></img>
<img src='@routes.Assets.at("assets/" + Play.configuration.getString("city-id").get + "/sidewalk-logo.png")' id="ps-logo-landscape"></img>
<div>
<p id="modal-landscape-header">
Welcome to Project Sidewalk!
Expand Down
2 changes: 1 addition & 1 deletion app/views/navbar.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div id="header-container" class="navbar-container container-fluid">
<div class="navbar-header">
<div class="navbar-logo">
<a id="brand navbar-brand" href="/"><img alt="Project Sidewalk Logo" height="40" src='@routes.Assets.at("assets/sidewalk-logo-new.png")'></a>
<a id="brand navbar-brand" href="/"><img alt="Project Sidewalk Logo" height="40" src='@routes.Assets.at("assets/" + Play.configuration.getString("city-id").get + "/sidewalk-logo.png")'></a>
</div>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
Expand Down
4 changes: 3 additions & 1 deletion app/views/validation.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@import play.api.libs.json.JsValue
@import views.html.bootstrap._

@(title: String, user: Option[User] = None, mission: Option[JsValue], labelList: Option[JsValue], progress: Option[JsValue], missionSetProgress: Int, hasNextMission: Boolean)(implicit lang: Lang)
@(title: String, user: Option[User] = None, mission: Option[JsValue], labelList: Option[JsValue], progress: Option[JsValue], missionSetProgress: Int, hasNextMission: Boolean, completedValidations: Int)(implicit lang: Lang)

@main(title, Some("/validate")) {
@navbar(user, Some("/validate"))
Expand Down Expand Up @@ -98,6 +98,7 @@
@Html(Messages("validate.bottom.ui.not.sure"))
</button>
</div>
<textarea id="validation-label-comment" placeholder="@Messages("validate.bottom.ui.add.comment")" class="validation-comment-box"></textarea>
</div>
</div>
<div id="modal-comment-holder" class="hidden">
Expand Down Expand Up @@ -283,6 +284,7 @@ <h1 class="status-holder-header-2" id="label-type-counterexample"></h1>
param.beaconDataStoreUrl = param.dataStoreUrl + "Beacon";
param.hasNextMission = @hasNextMission;
param.missionSetProgress = @missionSetProgress;
param.completedValidations = @completedValidations;
param.canvasHeight = 440;
param.canvasWidth = 720;
param.canvasCount = 1;
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scalariform.formatter.preferences._

name := """sidewalk-webpage"""

version := "6.8.3"
version := "6.8.4"

scalaVersion := "2.10.5"

Expand Down
13 changes: 2 additions & 11 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,8 @@ trustxforwarded=true

# Logger
# ~~~~~
# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .

# Root logger:
logger.root=ERROR

# Logger used by the framework:
logger.play=DEBUG

# Logger provided to your application:
logger.application=DEBUG
#logger.application=INFO
# We configured our own logback in conf/logger.xml (http://logback.qos.ch/).
#play.logger.includeConfigProperties=true -- doesn't work until a later version of Play

play {
akka {
Expand Down
5 changes: 5 additions & 0 deletions conf/evolutions/default/83.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# --- !Ups
INSERT INTO version VALUES ('6.8.4', now(), 'Adds a comment text field to the validation page.');

# --- !Downs
DELETE FROM version WHERE version_id = '6.8.4';
34 changes: 34 additions & 0 deletions conf/logger.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<configuration>

<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />

<timestamp key="bySecond" datePattern="yyyy-MMM-dd-HH:mm:ss"/>

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home}/logs/application-${SIDEWALK_CITY_ID}-${bySecond}.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread %n%message%n%xException%n</pattern>
</encoder>
</appender>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%coloredLevel %logger{15} - %message%n%xException{5}</pattern>
</encoder>
</appender>

<logger name="play" level="DEBUG" />
<logger name="application" level="DEBUG" />

<!-- Turn these ones off b/c they are annoying, and anyway we manage configuration ourselves -->
<logger name="com.avaje.ebean.config.PropertyMapLoader" level="OFF" />
<logger name="com.avaje.ebeaninternal.server.core.XmlConfigLoader" level="OFF" />
<logger name="com.avaje.ebeaninternal.server.lib.BackgroundThread" level="OFF" />
<logger name="com.gargoylesoftware.htmlunit.javascript" level="OFF" />

<root level="ERROR">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>

</configuration>
3 changes: 2 additions & 1 deletion conf/messages.en
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ navbar.admin = Admin

landing.create.path = Let''s create a path for everyone
landing.also.in = We are also in:
landing.mapathon = Live in {0}? Stop by <a class="exploremaplink" href="{1}" target="_blank">a mapathon event in your area!</a>
landing.mapathon = Live in {0}? Stop by <a id="mapathonLink" class="otherCityLink" href="{1}" target="_blank">a mapathon event in your area!</a>
landing.how.you.help = How you can help
landing.how.you.help.content = Virtually explore city streets to find and label accessibility issues in three easy steps—right from the comfort of your home.
landing.how.you.help.explore = EXPLORE
Expand Down Expand Up @@ -160,6 +160,7 @@ validate.left.ui.feedback = Feedback
validate.bottom.ui.agree = <u>A</u>gree
validate.bottom.ui.disagree = <u>D</u>isagree
validate.bottom.ui.not.sure = <u>N</u>ot sure
validate.bottom.ui.add.comment = Add comment here...
validate.right.ui.current.mission = Current Mission
validate.mission.complete.category = Category
validate.mission.complete.agree = Agree
Expand Down
23 changes: 12 additions & 11 deletions conf/messages.es
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ navbar.admin = Administrador

landing.create.path = Creemos un camino para todas las personas
landing.also.in = También estamos en:
landing.mapathon = ¿Vives en {0}? ¡Pasa por <a class="exploremaplink" href="{1}" target="_blank">un evento "mapathon" en tu área!</a>
landing.mapathon = ¿Vives en {0}? ¡Pasa por <a id="mapathonLink" class="otherCityLink" href="{1}" target="_blank">un evento "mapathon" en tu área!</a>
landing.how.you.help = Cómo puedes ayudar
landing.how.you.help.content = Explora virtualmente las calles de la ciudad para encontrar y etiquetar problemas de accesibilidad en tres sencillos pasos, directamente desde la comodidad de tu hogar.
landing.how.you.help.explore = EXPLORA
landing.how.you.help.find = ENCUENTRA PROBLEMAS
landing.how.you.help.assess = EVALÚA LA GRAVEDAD
landing.video.title = ¿Qué es Project Sidewalk?
landing.video.watch = Ver Ahora
landing.choropleth.title = Elige una colonia
landing.choropleth.content = Se te asignará automáticamente una colonia al hacer click en ''Comienza a explorar'', pero también puedes elegir una haciendo clic en cualquier zona del siguiente mapa.
landing.choropleth.legend = Porcentaje de la colonia completa
landing.choropleth.title = Elige un barrio
landing.choropleth.content = Se te asignará automáticamente un barrio al hacer click en ''Comienza a explorar'', pero también puedes elegir una haciendo clic en cualquier zona del siguiente mapa.
landing.choropleth.legend = Porcentaje del barrio completo
landing.stats.title = Tu trabajo está haciendo la diferencia
landing.stats.content.unfinished = Personas usuarias como tú ya han mapeado {0} millas de {1}, {2}—¡eso es el {3}% de la ciudad!
landing.stats.percent = de {0} mapeado
Expand Down Expand Up @@ -88,9 +88,9 @@ audit.left.ui.jump = Saltar
audit.left.ui.jump.title = Saltar a otra ubicación porque:
audit.left.ui.jump.button.explore = ¡Quiero explorar otra área!
audit.left.ui.jump.button.unavailable = No puedo ir en la dirección que quieres que camine.
audit.left.ui.jump.explore.title = ¿Ir a una nueva ubicación o una nueva colonia?
audit.left.ui.jump.explore.button.same.neighborhood = Ve a una nueva ubicación en esta colonia
audit.left.ui.jump.explore.button.new.neighborhood = Ir a una nueva colonia
audit.left.ui.jump.explore.title = ¿Ir a una nueva ubicación o un nuevo barrio?
audit.left.ui.jump.explore.button.same.neighborhood = Ve a una nueva ubicación en este barrio
audit.left.ui.jump.explore.button.new.neighborhood = Ir a un nuevo barrio

audit.right.ui.current.neighborhood = Colonia actual
audit.right.ui.miles = millas
Expand All @@ -104,10 +104,10 @@ audit.center.ui.temporary = Temporal (p. ej., construcción)
audit.center.ui.show.again = No mostrar de nuevo

audit.mission.complete.labels.title = Etiquetas de la misión
audit.mission.complete.progress.title = Progreso de la colonia
audit.mission.complete.progress.title = Progreso del barrio
audit.mission.complete.progress.mission.you = Exploraste en esta misión
audit.mission.complete.progress.neighborhood.you = Exploraste en esta colonia
audit.mission.complete.progress.neighborhood.others = Otras personas exploraron en esta colonia
audit.mission.complete.progress.neighborhood.you = Exploraste en este barrio
audit.mission.complete.progress.neighborhood.others = Otras personas exploraron en este barrio
audit.mission.complete.progress.neighborhood.remaining = Restante en este barrio
audit.mission.complete.legend.this.mission = Esta misión
audit.mission.complete.legend.previous.missions = Misiones anteriores
Expand Down Expand Up @@ -159,6 +159,7 @@ validate.left.ui.feedback = <span style="overflow-wrap: break-word;">Retroalimen
validate.bottom.ui.agree = De <u>a</u>cuerdo
validate.bottom.ui.disagree = No estoy <u>d</u>e acuerdo
validate.bottom.ui.not.sure = <u>N</u>o estoy de seguro
validate.bottom.ui.add.comment = Agrega un comentario aquí...
validate.right.ui.current.mission = Misión actual
validate.mission.complete.category = Categoría
validate.mission.complete.agree = De Acuerdo
Expand Down Expand Up @@ -217,7 +218,7 @@ results.reset.view = Restablecer vista
results.problems.per.mile = Problemas de banqueta por milla
results.legend.high = Alto
results.legend.low = Bajo
results.legend.body = Las colonias grises carecen de datos suficientes para evaluar los problemas de las banquetas. Haz clic en cualquier colonia para empezar a contribuir. Los resultados son preliminares y representan contribuciones voluntarias que aún no han sido validadas. Estamos trabajando en ello. ¡Manténte al tanto!
results.legend.body = Los barrios grises carecen de datos suficientes para evaluar los problemas de las banquetas. Haz clic en cualquier barrio para empezar a contribuir. Los resultados son preliminares y representan contribuciones voluntarias que aún no han sido validadas. Estamos trabajando en ello. ¡Manténte al tanto!

dashboard.audited.street = Calle auditada
dashboard.distance = Distancia total explorada
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
- "9000:9000"
environment:
- DATABASE_URL=jdbc:postgresql://db:5432/sidewalk
- SIDEWALK_CITY_ID=washington-dc
- SIDEWALK_EMAIL_ADDRESS=DUMMY_EMAIL_ADDRESS
- SIDEWALK_EMAIL_PASSWORD=DUMMY_EMAIL_PASSWORD

Expand Down
Loading

0 comments on commit 7678526

Please sign in to comment.