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

v7.8.0 #2999

Merged
merged 87 commits into from
Aug 19, 2022
Merged

v7.8.0 #2999

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
d2ed9d3
Adding popups to comment/feedback submissions
Z-Setiadi Jun 29, 2022
1045d16
changed Gallery cards with unsupported severiy ratings to have grayed…
davphan Jun 30, 2022
33419de
adjusted tooltip so it appears from severity display rather than tool…
davphan Jul 5, 2022
32588cf
adjusted modal popup popout with no severity to be grayed out smileys…
davphan Jul 5, 2022
4da0f3f
Merge branch 'develop' of https://github.com/ProjectSidewalk/Sidewalk…
misaugstad Jul 6, 2022
e2baa34
popover not working /labelMap?
Z-Setiadi Jul 6, 2022
626cac4
edits to use bootstrap popover
Z-Setiadi Jul 7, 2022
e82df1f
deletting message-popup stylesheets
Z-Setiadi Jul 7, 2022
ae21e41
High quality filter isn't working yet
bnelson05 Jul 8, 2022
0bc9e50
Still fixing high quality column
bnelson05 Jul 8, 2022
81dfe2b
removing labelModals when closed
Z-Setiadi Jul 8, 2022
c040002
Testing high quality value
bnelson05 Jul 11, 2022
cc64ded
Testing - filtered tasks is returning zero
bnelson05 Jul 13, 2022
bd35d9d
Half of the table is filtering correctly
bnelson05 Jul 13, 2022
b845db0
Merge branch 'develop' into 2771-giving-visual-feedback-when-comments…
Z-Setiadi Jul 13, 2022
717fabf
popover now works on labelMap
Z-Setiadi Jul 13, 2022
2422f80
popover now works on labelMap
Z-Setiadi Jul 13, 2022
770b07f
Merge branch '2771-giving-visual-feedback-when-comments-and-feedback-…
Z-Setiadi Jul 13, 2022
47c2349
Merge branch 'develop' of https://github.com/ProjectSidewalk/Sidewalk…
Z-Setiadi Jul 14, 2022
e4eb4c9
edits to popover code
Z-Setiadi Jul 14, 2022
b9ba3a5
Update validation.scala.html
Z-Setiadi Jul 14, 2022
45d1610
tooltip only for specific unsupported label types rather than all car…
davphan Jul 18, 2022
f3c0e62
gray out severity rating and added new custom tooltip for supported l…
davphan Jul 18, 2022
3ca6db8
Merge branch 'develop' of https://github.com/ProjectSidewalk/Sidewalk…
misaugstad Jul 19, 2022
5460c0e
removes severity rating data for pedestrian signals
misaugstad Jul 19, 2022
8587b62
Updated auditedStreetDistance cache
bnelson05 Jul 22, 2022
e49293c
fixed unsupported severity color/oopacity and centered modal tooltip
davphan Jul 28, 2022
a076a2f
Merge branch '2840-gray-severity-levels' of https://github.com/Projec…
davphan Jul 28, 2022
0b77e8c
Added high quality column to user table in admin dashboard
bnelson05 Jul 29, 2022
7313815
Functioning high quality column in admin dashboard
bnelson05 Jul 29, 2022
9155fa0
Merge branch 'develop' of https://github.com/ProjectSidewalk/Sidewalk…
Z-Setiadi Jul 29, 2022
f455bed
small admin page performance improvement
misaugstad Aug 1, 2022
e4aaa2c
Merge pull request #2977 from ProjectSidewalk/2966-admin-dashboard-us…
misaugstad Aug 1, 2022
6cec40b
changes order of cols in admin users table
misaugstad Aug 1, 2022
130c4ca
Merge branch 'develop' into 2952-update-admin-dashboard-to-filter-out…
misaugstad Aug 1, 2022
6bf5842
Fixes #2783 by changing the hyperlink url direct, adding turf script …
palbirmin Aug 2, 2022
8b957e9
Merge branch 'develop' of https://github.com/ProjectSidewalk/Sidewalk…
misaugstad Aug 2, 2022
0a88fcb
revert accidental change
misaugstad Aug 2, 2022
57855c0
Merge pull request #2983 from ProjectSidewalk/2783-neighborhood-hyper…
misaugstad Aug 2, 2022
a1eed94
Password reset email is no longer case sensitive
bnelson05 Aug 2, 2022
028c52b
Fixed filter code consistency
bnelson05 Aug 2, 2022
9353465
Merge pull request #2984 from ProjectSidewalk/2981-make-password-rese…
misaugstad Aug 2, 2022
414008f
Fixed code consistency
bnelson05 Aug 2, 2022
be4e8ad
Fixed code consistency
bnelson05 Aug 2, 2022
b981336
Merge branch '2952-update-admin-dashboard-to-filter-out-low-quality-d…
bnelson05 Aug 2, 2022
d3745aa
Merge pull request #2978 from ProjectSidewalk/2952-update-admin-dashb…
misaugstad Aug 2, 2022
5e90e8a
minor style changes
davphan Aug 5, 2022
fc4964f
Merge branch 'develop' into 2840-gray-severity-levels
misaugstad Aug 8, 2022
d02cf45
Merge pull request #2954 from ProjectSidewalk/2840-gray-severity-levels
misaugstad Aug 8, 2022
55d751d
style edits and fixing shifted popover
Z-Setiadi Aug 9, 2022
0120a41
Merge branch 'develop' of https://github.com/ProjectSidewalk/Sidewalk…
Z-Setiadi Aug 9, 2022
a13d86d
Merge branch '2771-giving-visual-feedback-when-comments-and-feedback-…
Z-Setiadi Aug 9, 2022
d8284f1
erasing whitespace
Z-Setiadi Aug 9, 2022
91f302d
Merge pull request #2951 from ProjectSidewalk/2771-giving-visual-feed…
misaugstad Aug 9, 2022
2a7a8f1
adds carousels of recent mistakes to user dashboard
misaugstad Aug 11, 2022
f7f9a7f
moves dashboard recent mistakes to async call in js
misaugstad Aug 15, 2022
239ac8a
fixes position of labels on user dashboard
misaugstad Aug 15, 2022
ae36ec8
adds note if validator did not add a comment
misaugstad Aug 15, 2022
44a5823
fixes indentation
misaugstad Aug 15, 2022
e8e6c22
adds img and note if no incorrect labels for a label type
misaugstad Aug 16, 2022
120055f
adds title to mistakes section on dashboard
misaugstad Aug 16, 2022
8beec23
sets a text area size for validator comments
misaugstad Aug 16, 2022
375f5d7
improves styling of label type titles in mistakes grid
misaugstad Aug 16, 2022
7b4b81e
adds tooltip to help explain user-contributed validations
misaugstad Aug 16, 2022
33cb36c
consolidates label type tranlsations, adding to user dashboard
misaugstad Aug 16, 2022
afc86cb
adds translations for recent mistakes on dashboard
misaugstad Aug 16, 2022
ab65fd7
moves utility function into it's own file
misaugstad Aug 16, 2022
b2d6872
fixes spacing of img and text when no validations to show
misaugstad Aug 16, 2022
201aa68
adds code comments for dashboard recent mistakes
misaugstad Aug 17, 2022
2c85074
upgrades i18next translation library
misaugstad Aug 17, 2022
0176fee
remove placeholder for label types with no validations on dashboard
misaugstad Aug 17, 2022
d5bed30
fixes indentation
misaugstad Aug 17, 2022
e8c3fe7
parallelizes checking for GSV imagery on user dashboard
misaugstad Aug 17, 2022
a379557
excludes labels from dashboard if majority vote says label is correct
misaugstad Aug 17, 2022
5cc5737
switches to 7 mistakes per label type on user dashboard
misaugstad Aug 17, 2022
984e2b3
moves funcs to convert to json to formats dir
misaugstad Aug 18, 2022
271b2f9
reduces size of organization name on user dashboard
misaugstad Aug 18, 2022
ae22abc
removes unused import
misaugstad Aug 18, 2022
c857c8c
Merge pull request #2994 from ProjectSidewalk/2288-user-dashboard-sho…
misaugstad Aug 18, 2022
7db8d53
fixes an issue with signing URLs for GSV
misaugstad Aug 18, 2022
0ee2e2c
fixes Gallery trying to show images that have expired
misaugstad Aug 18, 2022
77508b6
Merge pull request #2997 from ProjectSidewalk/2995-fixing-missing-ima…
misaugstad Aug 18, 2022
893259d
improves efficiency of Gallery checking for expired imagery
misaugstad Aug 19, 2022
06d27bd
parameterizes some code to check for GSV imagery
misaugstad Aug 19, 2022
6cdf5d9
parameterizes more code that checks for GSV imagery
misaugstad Aug 19, 2022
4bbe27d
Merge pull request #2998 from ProjectSidewalk/2661-improve-gallery-lo…
misaugstad Aug 19, 2022
48c58ca
7.7.0 -> 7.8.0
misaugstad Aug 19, 2022
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
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ module.exports = function(grunt) {
},
dist_progress: {
src: [
'public/javascripts/Progress/src/*.js'
'public/javascripts/Progress/src/*.js',
'public/javascripts/common/Utilities.js'
],
dest: 'public/javascripts/Progress/build/Progress.js'
},
Expand Down
7 changes: 4 additions & 3 deletions app/controllers/AdminController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import com.mohiva.play.silhouette.api.{Environment, Silhouette}
import com.mohiva.play.silhouette.impl.authenticators.SessionAuthenticator
import com.vividsolutions.jts.geom.Coordinate
import controllers.headers.ProvidesHeader
import formats.json.LabelFormat
import formats.json.TaskFormats._
import formats.json.UserRoleSubmissionFormats._
import formats.json.LabelFormat._
import models.attribute.{GlobalAttribute, GlobalAttributeTable}
import models.audit.{AuditTaskInteractionTable, AuditTaskTable, AuditedStreetWithTimestamp, InteractionWithLabel}
import models.daos.slick.DBTableDefinitions.UserTable
import models.gsv.GSVDataTable
import models.label.LabelTable.{LabelMetadata, LabelCVMetadata}
import models.label.LabelTable.{LabelCVMetadata, LabelMetadata}
import models.label.{LabelPointTable, LabelTable, LabelTypeTable, LabelValidationTable}
import models.mission.MissionTable
import models.region.RegionCompletionTable
Expand Down Expand Up @@ -355,7 +356,7 @@ class AdminController @Inject() (implicit val env: Environment[User, SessionAuth
case Some(labelPointObj) =>
val userId: String = request.identity.get.userId.toString
val labelMetadata: LabelMetadata = LabelTable.getSingleLabelMetadata(labelId, userId)
val labelMetadataJson: JsObject = LabelTable.labelMetadataWithValidationToJsonAdmin(labelMetadata)
val labelMetadataJson: JsObject = LabelFormat.labelMetadataWithValidationToJsonAdmin(labelMetadata)
Future.successful(Ok(labelMetadataJson))
case _ => Future.successful(Ok(Json.obj("error" -> "no such label")))
}
Expand All @@ -372,7 +373,7 @@ class AdminController @Inject() (implicit val env: Environment[User, SessionAuth
case Some(labelPointObj) =>
val userId: String = request.identity.map(_.userId.toString).getOrElse("")
val labelMetadata: LabelMetadata = LabelTable.getSingleLabelMetadata(labelId, userId)
val labelMetadataJson: JsObject = LabelTable.labelMetadataWithValidationToJson(labelMetadata)
val labelMetadataJson: JsObject = LabelFormat.labelMetadataWithValidationToJson(labelMetadata)
Future.successful(Ok(labelMetadataJson))
case _ => Future.successful(Ok(Json.obj("error" -> "no such label")))
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ForgotPasswordController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ForgotPasswordController @Inject() (
ForgotPasswordForm.form.bindFromRequest.fold (
form => Future.successful(BadRequest(views.html.forgotPassword(form))),
email => {
val loginInfo = LoginInfo(CredentialsProvider.ID, email)
val loginInfo = LoginInfo(CredentialsProvider.ID, email.toLowerCase)
val result = Redirect(routes.UserController.forgotPassword()).flashing("info" -> Messages("reset.pw.email.reset.pw.sent"))
userService.retrieve(loginInfo).flatMap {
case Some(user) =>
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/GalleryController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import models.label.{LabelTable, LabelTypeTable}
import models.label.LabelTable._
import com.mohiva.play.silhouette.api.{Environment, Silhouette}
import com.mohiva.play.silhouette.impl.authenticators.SessionAuthenticator
import formats.json.LabelFormat
import play.api.Play
import play.api.Play.current
import play.api.mvc._
import play.api.libs.json.{JsObject, Json, JsError}
import play.api.libs.json.{JsError, JsObject, Json}
import scala.concurrent.Future


Expand Down Expand Up @@ -65,7 +66,7 @@ class GalleryController @Inject() (implicit val env: Environment[User, SessionAu
} else labels

val jsonList: Seq[JsObject] = realLabels.map(l => Json.obj(
"label" -> LabelTable.validationLabelMetadataToJson(l),
"label" -> LabelFormat.validationLabelMetadataToJson(l),
"imageUrl" -> GoogleMapsHelper.getImageUrl(l.gsvPanoramaId, l.canvasWidth, l.canvasHeight, l.heading, l.pitch, l.zoom)
)
)
Expand Down
28 changes: 22 additions & 6 deletions app/controllers/UserProfileController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import com.mohiva.play.silhouette.api.{Environment, Silhouette}
import com.mohiva.play.silhouette.impl.authenticators.SessionAuthenticator
import com.vividsolutions.jts.geom.Coordinate
import controllers.headers.ProvidesHeader
import formats.json.LabelFormat.labelMetadataUserDashToJson
import models.audit.AuditTaskTable
import models.mission.MissionTable
import models.user.UserOrgTable
import models.label.{LabelTable, LabelValidationTable}
import models.user.{User, WebpageActivityTable, WebpageActivity}
import play.api.libs.json.{JsObject, Json}
import models.user.{User, WebpageActivity, WebpageActivityTable}
import play.api.libs.json.{JsObject, JsValue, Json}
import play.extras.geojson
import play.api.i18n.Messages
import scala.concurrent.Future
Expand All @@ -35,13 +36,14 @@ class UserProfileController @Inject() (implicit val env: Environment[User, Sessi
Future.successful(Redirect(s"/signIn?url=/"))
} else {
val user: User = request.identity.get
// Get distance audited by the user. If using metric units, convert from miles to kilometers.
val auditedDistance: Float =
if (Messages("measurement.system") == "metric") MissionTable.getDistanceAudited(user.userId) * 1.60934.toFloat
else MissionTable.getDistanceAudited(user.userId)
val timestamp: Timestamp = new Timestamp(Instant.now.toEpochMilli)
val ipAddress: String = request.remoteAddress
WebpageActivityTable.save(WebpageActivity(0, user.userId.toString, ipAddress, "Visit_UserDashboard", timestamp))
// Get distance audited by the user. If using metric units, convert from miles to kilometers.
val auditedDistance: Float = {
if (Messages("measurement.system") == "metric") MissionTable.getDistanceAudited(user.userId) * 1.60934.toFloat
else MissionTable.getDistanceAudited(user.userId)
}
Future.successful(Ok(views.html.userProfile(s"Project Sidewalk", Some(user), auditedDistance)))
}
}
Expand Down Expand Up @@ -154,6 +156,20 @@ class UserProfileController @Inject() (implicit val env: Environment[User, Sessi
Future.successful(Ok(json))
}

/**
* Get up `n` recent mistakes for each label type, using validations provided by other users.
* @param n Number of mistakes to retrieve for each label type.
* @return
*/
def getRecentMistakes(n: Int) = UserAwareAction.async {implicit request =>
val labelTypes: List[String] = List("CurbRamp", "NoCurbRamp", "Obstacle", "SurfaceProblem", "Crosswalk", "Signal")
val validations = LabelTable.getRecentValidatedLabelsForUser(request.identity.get.userId, n, labelTypes)
val validationJson: JsValue = Json.toJson(labelTypes.map { t =>
t -> validations.filter(_.labelType == t).map(labelMetadataUserDashToJson)
}.toMap)
Future.successful(Ok(validationJson))
}

/**
* Sets the org of the given user.
*
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/ValidationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import com.mohiva.play.silhouette.api.{Environment, Silhouette}
import com.mohiva.play.silhouette.impl.authenticators.SessionAuthenticator
import controllers.headers.ProvidesHeader
import formats.json.CommentSubmissionFormats._
import formats.json.LabelFormat
import models.amt.AMTAssignmentTable
import models.daos.slick.DBTableDefinitions.{DBUser, UserTable}
import models.label.LabelTable
import models.label.LabelTable.LabelValidationMetadata
import models.label.LabelValidationTable
import models.mission.{Mission, MissionTable, MissionSetProgress}
import models.mission.{Mission, MissionSetProgress, MissionTable}
import models.validation._
import models.user._
import play.api.libs.json._
Expand Down Expand Up @@ -138,7 +139,7 @@ class ValidationController @Inject() (implicit val env: Environment[User, Sessio
val labelsToRetrieve: Int = labelsToValidate - labelsProgress

val labelMetadata: Seq[LabelValidationMetadata] = LabelTable.retrieveLabelListForValidation(userId, labelsToRetrieve, labelType, skippedLabelId = None)
val labelMetadataJsonSeq: Seq[JsObject] = labelMetadata.map(label => LabelTable.validationLabelMetadataToJson(label))
val labelMetadataJsonSeq: Seq[JsObject] = labelMetadata.map(label => LabelFormat.validationLabelMetadataToJson(label))
val labelMetadataJson : JsValue = Json.toJson(labelMetadataJsonSeq)
labelMetadataJson
}
Expand Down
7 changes: 3 additions & 4 deletions app/controllers/ValidationTaskController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ import models.validation._
import play.api.libs.json._
import play.api.Logger
import play.api.mvc._

import scala.concurrent.Future
import scala.collection.mutable.ListBuffer
import formats.json.CommentSubmissionFormats._

import formats.json.LabelFormat
import java.time.Instant

/**
Expand Down Expand Up @@ -259,7 +258,7 @@ class ValidationTaskController @Inject() (implicit val env: Environment[User, Se
*/
def getLabelListForValidation(userId: UUID, n: Int, labelTypeId: Int): JsValue = {
val labelMetadata: Seq[LabelValidationMetadata] = LabelTable.retrieveLabelListForValidation(userId, n, labelTypeId, skippedLabelId = None)
val labelMetadataJsonSeq: Seq[JsObject] = labelMetadata.map(LabelTable.validationLabelMetadataToJson)
val labelMetadataJsonSeq: Seq[JsObject] = labelMetadata.map(LabelFormat.validationLabelMetadataToJson)
val labelMetadataJson : JsValue = Json.toJson(labelMetadataJsonSeq)
labelMetadataJson
}
Expand Down Expand Up @@ -288,7 +287,7 @@ class ValidationTaskController @Inject() (implicit val env: Environment[User, Se

val userId: UUID = request.identity.get.userId
val labelMetadata: LabelValidationMetadata = LabelTable.retrieveLabelListForValidation(userId, n = 1, labelTypeId, Some(skippedLabelId)).head
LabelTable.validationLabelMetadataToJson(labelMetadata)
LabelFormat.validationLabelMetadataToJson(labelMetadata)
}
Future.successful(Ok(labelMetadataJson.head))
}
Expand Down
101 changes: 100 additions & 1 deletion app/formats/json/LabelFormat.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package formats.json

import controllers.helper.GoogleMapsHelper
import models.label.LabelTable.{LabelMetadata, LabelMetadataUserDash, LabelValidationMetadata}
import java.sql.Timestamp

import models.label._
import play.api.libs.json._
import play.api.libs.functional.syntax._
Expand Down Expand Up @@ -52,4 +53,102 @@ object LabelFormat {
(__ \ "photographer_heading").write[Float] and
(__ \ "photographer_pitch").write[Float]
)(unlift(LabelTable.LabelCVMetadata.unapply _))

def validationLabelMetadataToJson(labelMetadata: LabelValidationMetadata): JsObject = {
Json.obj(
"label_id" -> labelMetadata.labelId,
"label_type" -> labelMetadata.labelType,
"gsv_panorama_id" -> labelMetadata.gsvPanoramaId,
"image_date" -> labelMetadata.imageDate,
"label_timestamp" -> labelMetadata.timestamp,
"heading" -> labelMetadata.heading,
"pitch" -> labelMetadata.pitch,
"zoom" -> labelMetadata.zoom,
"canvas_x" -> labelMetadata.canvasX,
"canvas_y" -> labelMetadata.canvasY,
"canvas_width" -> labelMetadata.canvasWidth,
"canvas_height" -> labelMetadata.canvasHeight,
"severity" -> labelMetadata.severity,
"temporary" -> labelMetadata.temporary,
"description" -> labelMetadata.description,
"user_validation" -> labelMetadata.userValidation.map(LabelValidationTable.validationOptions.get),
"tags" -> labelMetadata.tags
)
}

def labelMetadataWithValidationToJsonAdmin(labelMetadata: LabelMetadata): JsObject = {
Json.obj(
"label_id" -> labelMetadata.labelId,
"gsv_panorama_id" -> labelMetadata.gsvPanoramaId,
"tutorial" -> labelMetadata.tutorial,
"image_date" -> labelMetadata.imageDate,
"heading" -> labelMetadata.heading,
"pitch" -> labelMetadata.pitch,
"zoom" -> labelMetadata.zoom,
"canvas_x" -> labelMetadata.canvasXY._1,
"canvas_y" -> labelMetadata.canvasXY._2,
"canvas_width" -> labelMetadata.canvasWidth,
"canvas_height" -> labelMetadata.canvasHeight,
"audit_task_id" -> labelMetadata.auditTaskId,
"user_id" -> labelMetadata.userId,
"username" -> labelMetadata.username,
"timestamp" -> labelMetadata.timestamp,
"label_type_key" -> labelMetadata.labelTypeKey,
"label_type_value" -> labelMetadata.labelTypeValue,
"severity" -> labelMetadata.severity,
"temporary" -> labelMetadata.temporary,
"description" -> labelMetadata.description,
"user_validation" -> labelMetadata.userValidation.map(LabelValidationTable.validationOptions.get),
"num_agree" -> labelMetadata.validations("agree"),
"num_disagree" -> labelMetadata.validations("disagree"),
"num_notsure" -> labelMetadata.validations("notsure"),
"tags" -> labelMetadata.tags
)
}

// Has the label metadata excluding username, user_id, and audit_task_id.
def labelMetadataWithValidationToJson(labelMetadata: LabelMetadata): JsObject = {
Json.obj(
"label_id" -> labelMetadata.labelId,
"gsv_panorama_id" -> labelMetadata.gsvPanoramaId,
"tutorial" -> labelMetadata.tutorial,
"image_date" -> labelMetadata.imageDate,
"heading" -> labelMetadata.heading,
"pitch" -> labelMetadata.pitch,
"zoom" -> labelMetadata.zoom,
"canvas_x" -> labelMetadata.canvasXY._1,
"canvas_y" -> labelMetadata.canvasXY._2,
"canvas_width" -> labelMetadata.canvasWidth,
"canvas_height" -> labelMetadata.canvasHeight,
"timestamp" -> labelMetadata.timestamp,
"label_type_key" -> labelMetadata.labelTypeKey,
"label_type_value" -> labelMetadata.labelTypeValue,
"severity" -> labelMetadata.severity,
"temporary" -> labelMetadata.temporary,
"description" -> labelMetadata.description,
"user_validation" -> labelMetadata.userValidation.map(LabelValidationTable.validationOptions.get),
"num_agree" -> labelMetadata.validations("agree"),
"num_disagree" -> labelMetadata.validations("disagree"),
"num_notsure" -> labelMetadata.validations("notsure"),
"tags" -> labelMetadata.tags
)
}

def labelMetadataUserDashToJson(label: LabelMetadataUserDash): JsObject = {
Json.obj(
"label_id" -> label.labelId,
"gsv_panorama_id" -> label.gsvPanoramaId,
"heading" -> label.heading,
"pitch" -> label.pitch,
"zoom" -> label.zoom,
"canvas_x" -> label.canvasX,
"canvas_y" -> label.canvasY,
"canvas_width" -> label.canvasWidth,
"canvas_height" -> label.canvasHeight,
"label_type" -> label.labelType,
"time_validated" -> label.timeValidated,
"validator_comment" -> label.validatorComment,
"image_url" -> GoogleMapsHelper.getImageUrl(label.gsvPanoramaId, label.canvasWidth, label.canvasHeight, label.heading, label.pitch, label.zoom)
)
}
}
7 changes: 1 addition & 6 deletions app/models/audit/AuditTaskCommentTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import java.sql.Timestamp
import models.daos.slick.DBTableDefinitions.UserTable
import models.mission.{Mission, MissionTable}
import models.utils.MyPostgresDriver.simple._
import models.utils.CommonUtils.ordered
import models.validation.ValidationTaskCommentTable
import play.api.Play.current
import scala.slick.lifted.ForeignKeyQuery
Expand Down Expand Up @@ -80,10 +81,4 @@ object AuditTaskCommentTable {

(auditComments ++ validationComments).sortBy(_.timestamp).reverse.take(n)
}

// Defining ordered method for Timestamp so they can be used in sortBy.
// https://stackoverflow.com/questions/29985911/sort-scala-arraybuffer-of-timestamp
implicit def ordered: Ordering[Timestamp] = new Ordering[Timestamp] {
def compare(x: Timestamp, y: Timestamp): Int = x compareTo y
}
}
12 changes: 8 additions & 4 deletions app/models/daos/slick/UserDAOSlick.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import models.daos.UserDAO
import models.label.LabelValidationTable
import models.label.LabelTable
import models.mission.MissionTable
import models.user.{RoleTable, WebpageActivityTable}
import models.user.{RoleTable, WebpageActivityTable, UserStatTable}
import models.user.{UserRoleTable, User}
import play.api.db.slick._
import play.api.db.slick.Config.driver.simple._
Expand All @@ -22,7 +22,7 @@ case class UserStatsForAdminPage(userId: String, username: String, email: String
signUpTime: Option[Timestamp], lastSignInTime: Option[Timestamp], signInCount: Int,
completedMissions: Int, completedAudits: Int, labels: Int, ownValidated: Int,
ownValidatedAgreedPct: Double, ownValidatedDisagreedPct: Double, ownValidatedNotsurePct: Double,
othersValidated: Int, othersValidatedAgreedPct: Double)
othersValidated: Int, othersValidatedAgreedPct: Double, highQuality: Boolean)

class UserDAOSlick extends UserDAO {
/**
Expand Down Expand Up @@ -509,8 +509,11 @@ object UserDAOSlick {
(valCount._1, (valCount._2, valCount._3))
}.toMap

val userHighQuality =
UserStatTable.userStats.map { x => (x.userId, x.highQuality) }.list.toMap

// Now left join them all together and put into UserStatsForAdminPage objects.
usersMinusAnonUsersWithNoLabels.list.map{ u =>
usersMinusAnonUsersWithNoLabels.list.map { u =>
val ownValidatedCounts = validatedCounts.getOrElse(u.userId, ("", 0, 0, 0, 0))
val ownValidatedTotal = ownValidatedCounts._2
val ownValidatedAgreed = ownValidatedCounts._3
Expand Down Expand Up @@ -550,7 +553,8 @@ object UserDAOSlick {
ownValidatedDisagreedPct,
ownValidatedNotsurePct,
otherValidatedTotal,
otherValidatedAgreedPct
otherValidatedAgreedPct,
userHighQuality.getOrElse(u.userId, true)
)
}
}
Expand Down
Loading