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

fix edge case bug in parsers where avatarUrl is null #1137

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@ class ChallengeCommentRepository @Inject() (override val db: Database) extends R
object ChallengeCommentRepository {
val parser: RowParser[ChallengeComment] = {
long("id") ~ long("project_id") ~ long("challenge_id") ~ get[DateTime]("created") ~
get[String]("comment") ~ long("osm_id") ~ get[String]("name") ~ get[String]("avatar_url") map {
get[String]("comment") ~ long("osm_id") ~ get[String]("name") ~ get[Option[String]](
"avatar_url"
) map {
case id ~ projectId ~ challengeId ~ created ~ comment ~ osmId ~ name ~ avatarUrl =>
ChallengeComment(
id,
osmId,
name,
avatarUrl,
avatarUrl.getOrElse(""),
challengeId,
projectId,
created,
Expand All @@ -134,15 +136,17 @@ object ChallengeCommentRepository {

val expandedParser: RowParser[ChallengeComment] = {
long("id") ~ long("project_id") ~ long("challenge_id") ~ get[DateTime]("created") ~
get[String]("comment") ~ long("osm_id") ~ get[String]("name") ~ get[String]("avatar_url") ~ get[
get[String]("comment") ~ long("osm_id") ~ get[String]("name") ~ get[Option[String]](
"avatar_url"
) ~ get[
Option[String]
]("challenge_name") ~ get[Option[Int]]("full_count") map {
case id ~ projectId ~ challengeId ~ created ~ comment ~ osmId ~ name ~ avatarUrl ~ challengeName ~ fullCount =>
ChallengeComment(
id,
osmId,
name,
avatarUrl,
avatarUrl.getOrElse(""),
challengeId,
projectId,
created,
Expand Down
24 changes: 10 additions & 14 deletions app/org/maproulette/framework/repository/CommentRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,17 @@ class CommentRepository @Inject() (override val db: Database) extends Repository

object CommentRepository {
val parser: RowParser[Comment] = {
long("task_comments.id") ~ long("task_comments.osm_id") ~ get[String]("users.name") ~ get[
String
]("users.avatar_url") ~
long("task_comments.task_id") ~ long("task_comments.challenge_id") ~ long(
"task_comments.project_id"
) ~ get[DateTime]("task_comments.created") ~ get[String]("task_comments.comment") ~
long("task_comments.id") ~ long("task_comments.osm_id") ~ get[String]("users.name") ~
get[Option[String]]("users.avatar_url") ~ long("task_comments.task_id") ~
long("task_comments.challenge_id") ~ long("task_comments.project_id") ~
get[DateTime]("task_comments.created") ~ get[String]("task_comments.comment") ~
get[Option[Long]]("task_comments.action_id") map {
case id ~ osmId ~ name ~ avatarUrl ~ taskId ~ challengeId ~ projectId ~ created ~ comment ~ actionId =>
Comment(
id,
osm_id = osmId,
osm_username = name,
avatarUrl,
avatarUrl.getOrElse(""),
taskId = taskId,
challengeId = challengeId,
projectId = projectId,
Expand All @@ -189,19 +187,17 @@ object CommentRepository {
}

val expandedParser: RowParser[Comment] = {
long("task_comments.id") ~ long("task_comments.osm_id") ~ get[String]("users.name") ~ get[
String
]("users.avatar_url") ~
long("task_comments.task_id") ~ long("task_comments.challenge_id") ~ long(
"task_comments.project_id"
) ~ get[DateTime]("task_comments.created") ~ get[String]("task_comments.comment") ~
long("task_comments.id") ~ long("task_comments.osm_id") ~ get[String]("users.name") ~
get[Option[String]]("users.avatar_url") ~ long("task_comments.task_id") ~
long("task_comments.challenge_id") ~ long("task_comments.project_id") ~
get[DateTime]("task_comments.created") ~ get[String]("task_comments.comment") ~
get[Option[Long]]("task_comments.action_id") ~ get[Option[Int]]("full_count") map {
case id ~ osmId ~ name ~ avatarUrl ~ taskId ~ challengeId ~ projectId ~ created ~ comment ~ actionId ~ fullCount =>
Comment(
id,
osm_id = osmId,
osm_username = name,
avatarUrl,
avatarUrl.getOrElse(""),
taskId = taskId,
challengeId = challengeId,
projectId = projectId,
Expand Down