Skip to content

Commit

Permalink
recently taken reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
intracer committed Mar 17, 2024
1 parent e7874f6 commit 7394e16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions scalawiki-core/src/main/scala/org/scalawiki/dto/Image.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ import org.scalawiki.dto.markup.Gallery
import org.scalawiki.wikitext.TemplateParser
import org.sweble.wikitext.engine.nodes.EngPage

import scala.util.Try

case class ImageMetadata(data: Map[String, String]) {

def camera: Option[String] = data.get("Model")

def date: Option[ZonedDateTime] =
data
.get("DateTime")
.map(s => LocalDateTime.parse(s, ImageMetadata.df).atZone(ZoneOffset.UTC))
.get("DateTimeOriginal")
.flatMap { s =>
val parsed = Try(LocalDateTime.parse(s, ImageMetadata.df).atZone(ZoneOffset.UTC))
parsed.failed.foreach(println)
parsed.toOption
}
}

object ImageMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class RecentlyTaken(val stat: ContestStat) extends Reporter {
val images = db.images.filter(_.metadata.exists(_.date.exists(_.isAfter(jun30))))
images.map{ i =>
List(
s"[[File:${i.title}]]",
s"[[User:${i.author}|${i.author}]]",
s"[[:${i.title}]]",
s"[[User:${i.author.getOrElse("")}|${i.author.getOrElse("")}]]",
i.metadata.flatMap(_.date.map(_.toString)).getOrElse("")
)

Expand Down

0 comments on commit 7394e16

Please sign in to comment.