Skip to content

Commit

Permalink
Add case class for KeywordCount
Browse files Browse the repository at this point in the history
  • Loading branch information
bryophyta committed Sep 24, 2024
1 parent 1389f93 commit f5d59c7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions newswires/app/db/FingerpostWireEntry.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ object FingerpostWireEntry extends SQLSyntaxSupport[FingerpostWireEntry] {
.fold(sqls"")(inLastHours =>
sqls"WHERE ingested_at > now() - ($inLastHours::text || ' hours')::interval"
)
println(innerWhereClause)
val limitClause = maybeLimit
.map(limit => sqls"LIMIT $limit")
.orElse(maybeInLastHours.map(_ => sqls"LIMIT 10"))
Expand All @@ -117,7 +116,13 @@ object FingerpostWireEntry extends SQLSyntaxSupport[FingerpostWireEntry] {
.map(rs => rs.string("keyword") -> rs.int("count"))
.list()
.apply()
.toMap // TODO would a list be better?
.map { case (keyword, count) => KeywordCount(keyword, count) }
}

}

case class KeywordCount(keyword: String, count: Int)

object KeywordCount {
implicit val format: OFormat[KeywordCount] = Json.format[KeywordCount]
}

0 comments on commit f5d59c7

Please sign in to comment.