Skip to content
This repository has been archived by the owner on Oct 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #228 from MITLibraries/223_apply_deprecated
Browse files Browse the repository at this point in the history
Resolves deprecation warning
  • Loading branch information
JPrevost committed Jun 24, 2015
2 parents 8ee6325 + 942cd23 commit f063fe9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/models/Subscriber.scala
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,20 @@ case class Subscriber(id: Int, // DB key
val stimestamp = Timestamp.valueOf(start)
val etimestamp = Timestamp.valueOf(end)

def transferCount(total: Int, deliverCount: Int, discardCount: Int) = {
List(total, deliverCount, discardCount)
}

val transferCount_parser = {
get[Int] ("total") ~
get[Int] ("deliverCount") ~
get[Int] ("discardCount") map({
case total~deliverCount~discardCount => transferCount(total, deliverCount, discardCount)
})
}

DB.withConnection { implicit c =>
val rows = SQL(
SQL(
"""
SELECT count(*) as total,
COALESCE(sum(CASE WHEN action = 'deliver' then 1 else 0 end), 0) deliverCount,
Expand All @@ -235,7 +247,7 @@ case class Subscriber(id: Int, // DB key
WHERE subscriber_id = {id}
AND created BETWEEN {stimestamp} AND {etimestamp}
""").on('id -> id, 'stimestamp -> stimestamp, 'etimestamp -> etimestamp)
rows().map(row => List(row[Int]("total"), row[Int]("deliverCount"), row[Int]("discardCount"))).head
.as(transferCount_parser single)
}
}

Expand Down

0 comments on commit f063fe9

Please sign in to comment.