Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
intracer committed Mar 16, 2024
1 parent 8657e27 commit 56006a3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package org.scalawiki.wlx.stat.rating
import org.scalawiki.wlx.stat.ContestStat

case class NewlyPicturedPerAuthorBonus(
stat: ContestStat,
newlyPicturedRate: Double,
newlyPicturedPerAuthorRate: Double
) extends Rater {
stat: ContestStat,
newlyPicturedRate: Double,
newlyPicturedPerAuthorRate: Double
) extends Rater {

val oldMonumentIdsByAuthor: Map[String, Set[String]] = oldImages
.groupBy(_.author.getOrElse(""))
Expand All @@ -19,9 +19,9 @@ case class NewlyPicturedPerAuthorBonus(
case id if !oldMonumentIds.contains(id) =>
newlyPicturedRate - 1
case id
if !oldMonumentIdsByAuthor
.getOrElse(author, Set.empty)
.contains(id) =>
if !oldMonumentIdsByAuthor
.getOrElse(author, Set.empty)
.contains(id) =>
newlyPicturedPerAuthorRate - 1
case _ =>
0
Expand All @@ -36,9 +36,9 @@ case class NewlyPicturedPerAuthorBonus(
case id if !oldMonumentIds.contains(id) =>
s"Newly pictured bonus = ${newlyPicturedRate - 1}"
case id
if !oldMonumentIdsByAuthor
.getOrElse(author, Set.empty)
.contains(id) =>
if !oldMonumentIdsByAuthor
.getOrElse(author, Set.empty)
.contains(id) =>
s"Newly pictured per author bonus = ${newlyPicturedPerAuthorRate - 1}"
case _ =>
s"Not newly pictured = 0"
Expand All @@ -47,6 +47,6 @@ case class NewlyPicturedPerAuthorBonus(

override def disqualify(monumentId: String, author: String): Boolean = {
Set("Петро Халява", "SnizhokAM").contains(author) &&
oldMonumentIdsByAuthor.getOrElse(author, Set.empty).contains(monumentId)
oldMonumentIdsByAuthor.getOrElse(author, Set.empty).contains(monumentId)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import org.scalawiki.wlx.stat.reports.RateInputDistribution
import scala.collection.mutable

case class NumberOfImagesInPlaceBonus(
stat: ContestStat,
rateRanges: RateRanges
) extends Rater {
stat: ContestStat,
rateRanges: RateRanges
) extends Rater {

val oldImagesDb = new ImageDB(stat.contest, oldImages, stat.monumentDb)
val perPlaceStat = PerPlaceStat(oldImagesDb)
Expand Down Expand Up @@ -82,4 +82,4 @@ case class NumberOfImagesInPlaceBonus(
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package org.scalawiki.wlx.stat.rating

import org.scalawiki.wlx.stat.ContestStat

case class NumberOfMonuments(stat: ContestStat, baseRate: Double)
extends Rater {
case class NumberOfMonuments(stat: ContestStat, baseRate: Double) extends Rater {
val monumentIds = stat.monumentDb.map(_.ids).getOrElse(Set.empty)

override def rate(monumentId: String, author: String): Double = {
Expand All @@ -18,8 +17,7 @@ case class NumberOfMonuments(stat: ContestStat, baseRate: Double)
override def withRating: Boolean = false
}

case class NewlyPicturedBonus(stat: ContestStat, newlyPicturedRate: Double)
extends Rater {
case class NewlyPicturedBonus(stat: ContestStat, newlyPicturedRate: Double) extends Rater {

override def rate(monumentId: String, author: String): Double = {
if (!oldMonumentIds.contains(monumentId))
Expand All @@ -34,4 +32,4 @@ case class NewlyPicturedBonus(stat: ContestStat, newlyPicturedRate: Double)
else
"Not newly pictured = 0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package org.scalawiki.wlx.stat.rating
import org.scalawiki.wlx.ImageDB

case class PerPlaceStat(
imagesPerPlace: Map[String, Int],
placeByMonument: Map[String, String]
) {
imagesPerPlace: Map[String, Int],
placeByMonument: Map[String, String]
) {
val distribution = placeByMonument.values
.map(place => imagesPerPlace.getOrElse(place, 0))
.groupBy(identity)
Expand Down Expand Up @@ -111,10 +111,10 @@ object PerPlaceStat {
id <- imageDB.ids.toSeq;
place <- monumentDb.placeByMonumentId.get(id)
)
yield (place -> imageDB.byId(id).size))
yield (place -> imageDB.byId(id).size))
.groupBy(_._1)
.mapValues(_.map(_._2).sum)

PerPlaceStat(imagesPerPlace.toMap, monumentDb.placeByMonumentId)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.scalawiki.wlx.stat.ContestStat

import scala.util.Try


trait Rater {

def stat: ContestStat
Expand Down Expand Up @@ -100,4 +99,4 @@ object Rater {
}

}
}
}

0 comments on commit 56006a3

Please sign in to comment.