Skip to content

Commit

Permalink
revert type changes to groups
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Aug 13, 2024
1 parent 8edfd8a commit b6b5066
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ class TeamSchema @Inject() (override val service: TeamService)
case Some(description) => Some(description)
case None => team.description
},
avatarURL = context.arg(TeamSchema.avatarUrlArg)
avatarURL = context.arg(TeamSchema.avatarUrlArg) match {
case Some(avatarURL) => Some(avatarURL)
case None => team.avatarURL
}
),
user
)
Expand Down Expand Up @@ -205,10 +208,10 @@ object TeamSchema extends DefaultWrites {
OptionInputType(StringType),
"The description of the object"
)
val avatarUrlArg: Argument[String] =
val avatarUrlArg: Argument[Option[String]] =
Argument(
"avatarURL",
StringType,
OptionInputType(StringType),
"An avatar URL representing the object"
)
}
4 changes: 2 additions & 2 deletions app/org/maproulette/framework/model/Group.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ case class Group(
id: Long,
name: String,
description: Option[String] = None,
avatarURL: String,
avatarURL: Option[String] = None,
groupType: Int = Group.GROUP_TYPE_STANDARD,
created: DateTime = DateTime.now(),
modified: DateTime = DateTime.now()
Expand All @@ -34,7 +34,7 @@ object Group extends CommonField {
(JsPath \ "id").read[Long] and
(JsPath \ "name").read[String] and
(JsPath \ "description").readNullable[String] and
(JsPath \ "avatarURL").read[String] and
(JsPath \ "avatarURL").readNullable[String] and
(JsPath \ "groupType").read[Int] and
((JsPath \ "created").read[DateTime] or Reads.pure(DateTime.now())) and
((JsPath \ "modified").read[DateTime] or Reads.pure(DateTime.now()))
Expand Down
16 changes: 2 additions & 14 deletions app/org/maproulette/framework/repository/UserRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,7 @@ class UserRepository @Inject() (
case None =>
val group = this.serviceManager.group
.create(
Group(
-1,
s"User ${follower.id} Following",
Some(""),
"",
groupType = Group.GROUP_TYPE_FOLLOWING
)
Group(-1, s"User ${follower.id} Following", groupType = Group.GROUP_TYPE_FOLLOWING)
)
.get
this.setupGroup("following_group", group.id, follower.id)
Expand All @@ -189,13 +183,7 @@ class UserRepository @Inject() (
case None =>
val group = this.serviceManager.group
.create(
Group(
-1,
s"User ${followed.id} Followers",
Some(""),
"",
groupType = Group.GROUP_TYPE_FOLLOWERS
)
Group(-1, s"User ${followed.id} Followers", groupType = Group.GROUP_TYPE_FOLLOWERS)
)
.get
this.setupGroup("followers_group", group.id, followed.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class GroupMemberRepositorySpec(implicit val application: Application) extends F
-1,
name,
Some("A test group"),
"http://www.gravatar.com/avatar/?d=identicon",
Some("http://www.gravatar.com/avatar/?d=identicon"),
groupType
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ class GroupRepositorySpec(implicit val application: Application) extends Framewo
}

"create a group" taggedAs GroupTag in {
val createdGroup = this.repository.create(Group(-1, "RandomCreateGroup", Some(""), "")).get
val createdGroup = this.repository.create(Group(-1, "RandomCreateGroup")).get
val retrievedGroup = this.repository.retrieve(createdGroup.id)
retrievedGroup.get mustEqual createdGroup
}

"update a group" taggedAs GroupTag in {
val randomGroup = this.repository.create(Group(-1, "RandomGroup", Some(""), "")).get
val randomGroup = this.repository.create(Group(-1, "RandomGroup")).get
this.repository.update(
Group(randomGroup.id, "UpdatedName", Some("Updated description"), "new_avatar_url")
Group(randomGroup.id, "UpdatedName", Some("Updated description"), Some("new_avatar_url"))
)
val group = this.service.retrieve(randomGroup.id)
group.get.name mustEqual "UpdatedName"
group.get.description.get mustEqual "Updated description"
group.get.avatarURL mustEqual "new_avatar_url"
group.get.avatarURL.get mustEqual "new_avatar_url"
}

"delete a group" taggedAs GroupTag in {
val group = this.repository.create(Group(-1, "RandomDeleteGroup", Some(""), "")).get
val group = this.repository.create(Group(-1, "RandomDeleteGroup")).get
this.repository.delete(group)
this.service.retrieve(group.id) mustEqual None
}
Expand All @@ -73,7 +73,7 @@ class GroupRepositorySpec(implicit val application: Application) extends Framewo
-1,
name,
Some("A test group"),
"http://www.gravatar.com/avatar/?d=identicon"
Some("http://www.gravatar.com/avatar/?d=identicon")
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class GroupServiceSpec(implicit val application: Application) extends FrameworkH
-1,
name,
Some("A test group"),
"http://www.gravatar.com/avatar/?d=identicon"
Some("http://www.gravatar.com/avatar/?d=identicon")
)
}
}
2 changes: 1 addition & 1 deletion test/org/maproulette/framework/util/FrameworkHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ trait FrameworkHelper extends PlaySpec with BeforeAndAfterAll with MockitoSugar
-1,
name,
Some("A test team"),
"http://www.gravatar.com/avatar/?d=identicon"
Some("http://www.gravatar.com/avatar/?d=identicon")
)
}

Expand Down

0 comments on commit b6b5066

Please sign in to comment.