Skip to content

disqualify by taken date #503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 33 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
50861c2
test raters' config by pattern match
intracer Mar 16, 2024
58c52e6
move rating to separate package
intracer Mar 16, 2024
f16ca43
move classes to separate files
intracer Mar 16, 2024
8657e27
optimize getting special nominations, cleanup
intracer Mar 16, 2024
56006a3
reformat
intracer Mar 16, 2024
e49ec48
cleanup
intracer Mar 16, 2024
990d8e8
fix test
intracer Mar 16, 2024
9d08250
cleanup
intracer Mar 16, 2024
0b33d14
fix compilation
intracer Mar 16, 2024
e7874f6
recently taken reporter
intracer Mar 17, 2024
7394e16
recently taken reporter
intracer Mar 17, 2024
9d0e130
recently taken exclude special nominations
intracer Mar 19, 2024
8c26d75
fixes
intracer Apr 3, 2024
69b94b2
Merge remote-tracking branch 'origin/disqualify-by-taken-date' into d…
intracer Apr 3, 2024
c99edc5
fix
intracer Apr 12, 2024
5f2c882
Merge remote-tracking branch 'origin/master' into disqualify-by-taken…
intracer Jul 6, 2024
49acd10
mime
intracer Jul 6, 2024
f5ec789
Merge remote-tracking branch 'origin/disqualify-by-taken-date' into d…
intracer Jul 6, 2024
066ae9b
Merge remote-tracking branch 'origin/master' into disqualify-by-taken…
intracer Sep 21, 2024
25722b3
simplify
intracer Sep 22, 2024
a6487e2
Польська спадщина, simplify
intracer Oct 5, 2024
418aa45
query only total not in years images
intracer Oct 5, 2024
3a51528
query only total not in years images fixes
intracer Oct 6, 2024
afdfd60
year 2024 configs
intracer Oct 6, 2024
14fec56
year 2024 configs
intracer Oct 11, 2024
a8f2cd3
cleanup
intracer Oct 11, 2024
4cb859b
2023 to 2024
intracer Oct 20, 2024
e709431
fix contest name
intracer Oct 20, 2024
2bbb41b
page parse returns option
intracer Oct 21, 2024
806cb50
newly pictured special nomination galleries
intracer Oct 28, 2024
ba50649
special nomination galleries by region per region pages
intracer Dec 15, 2024
1f72c69
Merge remote-tracking branch 'refs/remotes/origin/master' into disqua…
intracer Mar 29, 2025
6d5d39e
move to pekko
intracer Mar 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

## Directory-based project format:
.idea/
null/

## File-based project format:
*.ipr
Expand Down
3 changes: 2 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
version = 3.8.3
runner.dialect = scala213
runner.dialect = scala213
maxColumn = 100
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

14 changes: 7 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ lazy val core = Project("scalawiki-core", file("scalawiki-core"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= {
Seq(
Library.Akka.actor,
Library.Akka.stream,
Library.Akka.http,
Library.Akka.httpCaching,
Library.Pekko.actor,
Library.Pekko.stream,
Library.Pekko.http,
Library.Pekko.httpCaching,
Library.Play.json(isScala213.value),
"com.typesafe" % "config" % TypesafeConfigV,
"com.iheart" %% "ficus" % FicusV,
Expand Down Expand Up @@ -125,9 +125,9 @@ lazy val `http-extensions` = (project in file("http-extensions"))
.settings(commonSettings: _*)
.settings(
libraryDependencies ++= Seq(
Library.Akka.actor,
Library.Akka.stream,
Library.Akka.http,
Library.Pekko.actor,
Library.Pekko.stream,
Library.Pekko.http,
"org.scalacheck" %% "scalacheck" % ScalaCheckV % Test
)
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package net.spraycookies

import akka.http.scaladsl.client.RequestBuilding
import akka.http.scaladsl.model.headers.{Cookie, `Set-Cookie`}
import akka.http.scaladsl.model.{HttpRequest, HttpResponse, Uri}
import org.apache.pekko.http.scaladsl.client.RequestBuilding
import org.apache.pekko.http.scaladsl.model.headers.{Cookie, `Set-Cookie`}
import org.apache.pekko.http.scaladsl.model.{HttpRequest, HttpResponse, Uri}

import scala.concurrent.{ExecutionContext, Future}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.spraycookies

import akka.http.scaladsl.model.{DateTime, Uri}
import akka.http.scaladsl.model.headers.HttpCookie
import org.apache.pekko.http.scaladsl.model.{DateTime, Uri}
import org.apache.pekko.http.scaladsl.model.headers.HttpCookie
import net.spraycookies.tldlist.EffectiveTldList

import scala.annotation.tailrec
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package net.spraycookies

import akka.http.scaladsl.model.headers.HttpCookie
import org.apache.pekko.http.scaladsl.model.headers.HttpCookie
import org.scalacheck.Properties
import org.scalacheck.Prop.forAll
import org.scalacheck.Gen

object CookieJarSpecification extends Properties("CookieHandling") {

import akka.http.scaladsl.model.headers.{Cookie, `Set-Cookie`}
import akka.http.scaladsl.model.{HttpRequest, HttpResponse, Uri}
import org.apache.pekko.http.scaladsl.model.headers.{Cookie, `Set-Cookie`}
import org.apache.pekko.http.scaladsl.model.{HttpRequest, HttpResponse, Uri}
import net.spraycookies.tldlist.EffectiveTldList
import scala.concurrent._
import scala.concurrent.duration._
Expand Down
16 changes: 8 additions & 8 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object Dependencies {
)

val overrides = Seq(
Library.Akka.actor,
Library.Pekko.actor,
"org.reactivestreams" % "reactive-streams" % ReactiveStreamsV,
"org.scala-lang.modules" %% "scala-xml" % ScalaXmlV,
"org.scala-lang.modules" %% "scala-parser-combinators" % ScalaParserCombinatorsV,
Expand All @@ -63,14 +63,14 @@ object Dependencies {

object Library {

object Akka {
val AkkaV = "2.6.20"
val AkkaHttpV = "10.1.15"
object Pekko {
val PekkoV = "1.0.3"
val PekkoHttpV = "1.0.1"

val actor = "com.typesafe.akka" %% "akka-actor" % AkkaV
val stream = "com.typesafe.akka" %% "akka-stream" % AkkaV
val http = "com.typesafe.akka" %% "akka-http" % AkkaHttpV
val httpCaching = "com.typesafe.akka" %% "akka-http-caching" % AkkaHttpV
val actor = "org.apache.pekko" %% "pekko-actor" % PekkoV
val stream = "org.apache.pekko" %% "pekko-stream" % PekkoV
val http = "org.apache.pekko" %% "pekko-http" % PekkoHttpV
val httpCaching = "org.apache.pekko" %% "pekko-http-caching" % PekkoHttpV
}

object Play {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package org.scalawiki.bots.stat

import java.util.Collections
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicInteger

import akka.actor.ActorSystem
import akka.http.caching.LfuCache
import akka.http.caching.javadsl.CachingSettings
import akka.http.caching.scaladsl.Cache
import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.http.caching.LfuCache
import org.apache.pekko.http.caching.scaladsl.Cache
import org.scalawiki.MwBot
import org.scalawiki.dto.{Namespace, Page}
import org.scalawiki.dto.cmd.Action
import org.scalawiki.dto.cmd.query.list._
import org.scalawiki.dto.cmd.query.prop._
import org.scalawiki.dto.cmd.query.{Generator, Query}
import org.scalawiki.dto.{Namespace, Page}

import java.util.Collections
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicInteger
import scala.collection.JavaConverters._
import scala.collection.SortedSet
import scala.concurrent.ExecutionContext.Implicits.global
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.scalawiki.bots.stat.zachte

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import org.jsoup.Jsoup
import org.scalawiki.MwBot
import org.scalawiki.http.HttpClient
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.scalawiki

import akka.actor.ActorSystem
import org.scalawiki.http.HttpClientAkka
import org.apache.pekko.actor.ActorSystem
import org.scalawiki.http.HttpClientPekko
import org.specs2.mutable.Specification

import scala.concurrent.{Await, Future}
Expand All @@ -14,7 +14,7 @@ class BaseIntegrationSpec extends Specification {
val commons = "commons.wikimedia.org"

val system: ActorSystem = ActorSystem()
val http = new HttpClientAkka(system)
val http = new HttpClientPekko(system)

def getUkWikiBot: MwBot = MwBot.fromHost(ukWiki)

Expand Down
7 changes: 6 additions & 1 deletion scalawiki-core/src/main/resources/application.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
akka.http.parsing {
pekko.http.parsing {
max-content-length = 16m
max-to-strict-bytes = 16m
}

pekko.default-dispatcher {
type = Dispatcher
executor = "thread-pool-executor"
}
16 changes: 8 additions & 8 deletions scalawiki-core/src/main/scala/org/scalawiki/MwBot.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.scalawiki

import akka.actor.ActorSystem
import akka.event.LoggingAdapter
import akka.http.caching.LfuCache
import akka.http.scaladsl.model.Uri.Query
import akka.http.scaladsl.model._
import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.event.LoggingAdapter
import org.apache.pekko.http.caching.LfuCache
import org.apache.pekko.http.scaladsl.model.Uri.Query
import org.apache.pekko.http.scaladsl.model._
import org.jsoup.Jsoup
import org.scalawiki.dto.cmd.Action
import org.scalawiki.dto.{LoginResponse, MwException, Page, Site}
Expand All @@ -25,6 +25,8 @@ trait ActionBot {
limit: Option[Long] = None
): Future[Iterable[Page]]

def log: LoggingAdapter

}

trait MwBot extends ActionBot {
Expand Down Expand Up @@ -70,8 +72,6 @@ trait MwBot extends ActionBot {

def system: ActorSystem

def log: LoggingAdapter

def mediaWikiVersion: MediaWikiVersion
}

Expand Down Expand Up @@ -309,7 +309,7 @@ class MwBotImpl(

object MwBot {

import akka.http.caching.scaladsl.Cache
import org.apache.pekko.http.caching.scaladsl.Cache

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent._
Expand Down
65 changes: 31 additions & 34 deletions scalawiki-core/src/main/scala/org/scalawiki/dto/Image.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,25 @@ 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 {
val pattern = "yyyy:MM:dd HH:mm:ss"
val df = DateTimeFormatter.ofPattern(pattern)
private val pattern = "yyyy:MM:dd HH:mm:ss"
private val df = DateTimeFormatter.ofPattern(pattern)
}

case class Image(
Expand All @@ -38,7 +44,8 @@ case class Image(
pageId: Option[Long] = None,
metadata: Option[ImageMetadata] = None,
categories: Set[String] = Set.empty,
specialNominations: Set[String] = Set.empty
specialNominations: Set[String] = Set.empty,
mime: Option[String] = None
) extends Ordered[Image] {

def compare(that: Image): Int = title.compareTo(that.title)
Expand Down Expand Up @@ -82,7 +89,7 @@ object Image {
def fromPageRevision(
page: Page,
monumentIdTemplate: Option[String],
specialNominationTemplates: Seq[String] = Nil
specialNominationTemplates: Set[String] = Set.empty
): Option[Image] = {
page.revisions.headOption.map { revision =>
val content = revision.content.getOrElse("")
Expand All @@ -92,12 +99,8 @@ object Image {
.collectTemplates(parsedPage, template)
.flatMap(_.getParamOpt("1"))
}
val specialNominations = specialNominationTemplates.flatMap { template =>
Some(template).filter(_ => {
val value = TemplateParser.collectTemplates(parsedPage, template)
value.nonEmpty
})
}
val specialNominations =
TemplateParser.collectTemplateNames(parsedPage, specialNominationTemplates)

val author = getAuthorFromPage(parsedPage)

Expand All @@ -115,40 +118,32 @@ object Image {
monumentIds = ids,
pageId = page.id,
categories = categories,
specialNominations = specialNominations.toSet
specialNominations = specialNominations
)
}
}

def fromPage(
page: Page,
monumentIdTemplate: Option[String],
specialNominationTemplates: Seq[String] = Nil
): Option[Image] = {
for (
fromImage <- Image.fromPageImages(page);
specialNominationTemplates: Set[String] = Set.empty
)(page: Page): Option[Image] =
for {
fromImage <- Image.fromPageImages(page)
fromRev <- Image.fromPageRevision(
page,
monumentIdTemplate,
specialNominationTemplates
)
renamedAuthor = fromRev.author.map(author => AuthorsMap.renames.getOrElse(author, author))
} yield fromImage.copy(
monumentIds = fromRev.monumentIds,
author = renamedAuthor,
categories = fromRev.categories,
specialNominations = fromRev.specialNominations
)
yield {
val renamedAuthor = fromRev.author.map(author =>
AuthorsMap.renames.getOrElse(author, author)
)
fromImage.copy(
monumentIds = fromRev.monumentIds,
author = renamedAuthor,
categories = fromRev.categories,
specialNominations = fromRev.specialNominations
)
}
}

def getAuthorFromPage(content: String): String = {
def getAuthorFromPage(content: String): String =
getAuthorFromPage(TemplateParser.parsePage(content))
}

def getAuthorFromPage(parsedPage: EngPage): String = {
val template = TemplateParser.getTemplate(parsedPage, Some("Information"))
Expand Down Expand Up @@ -198,7 +193,8 @@ object Image {
url: Option[String],
pageUrl: Option[String],
pageId: Option[Long],
metadata: Option[Map[String, String]] = None
metadata: Option[Map[String, String]] = None,
mime: Option[String] = None
) =
new Image(
title = title,
Expand All @@ -210,7 +206,8 @@ object Image {
url = url,
pageUrl = pageUrl,
pageId = pageId,
metadata = metadata.map(ImageMetadata.apply)
metadata = metadata.map(ImageMetadata.apply),
mime = mime
)

def gallery(
Expand Down
Loading
Loading