Permalink
Browse files

Replace .get by .getOrElse (where useful)

  • Loading branch information...
1 parent 4080193 commit 38cf94be45d9fbd32f4f526e5a8e195f7ee6550f @Dinduks committed Sep 14, 2012
Showing with 8 additions and 7 deletions.
  1. +7 −6 app/models/Repository.scala
  2. +1 −1 app/views/helper/repositoryLink.scala.html
@@ -64,18 +64,19 @@ object Repository {
def computeContributors(commits: List[Commit]): List[Contributor] = {
var contributorsMap: Map[String, Contributor] = Map()
- for (commit <- commits) {
- val key = commit.author.get.username.getOrElse(commit.author.get.email.get)
+ for (commit <- commits; author <- commit.author) {
+ val key = author.username.getOrElse(author.email.getOrElse(""))
+
contributorsMap.get(key) match {
case Some(contributor) => {
contributor.contributionsCounter = contributor.contributionsCounter + 1
}
case None => {
val contributor = Contributor(
- (commit.author.get.username),
- (commit.author.get.name),
- (commit.author.get.email),
- (commit.author.get.avatarUrl),
+ (commit.author.getOrElse(new User).username),
+ (commit.author.getOrElse(new User).name),
+ (commit.author.getOrElse(new User).email),
+ (commit.author.getOrElse(new User).avatarUrl),
1
)
@@ -2,7 +2,7 @@
@import revontulet.Util
-@defining(Util.trim(repo.owner.get.toString, '"') + "/" + Util.trim(repo.name.get.toString, '"')) { repositoryFullName =>
+@defining(Util.trim(repo.owner.getOrElse("").toString, '"') + "/" + Util.trim(repo.name.getOrElse("").toString, '"')) { repositoryFullName =>
<a href="/@repositoryFullName">
@repositoryFullName
</a>

0 comments on commit 38cf94b

Please sign in to comment.