-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1324 from GiganticMinecraft/develop
- Loading branch information
Showing
12 changed files
with
109 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/main/resources/db/migration/V1.7.4__Create_Slow_Query_Index_ranking.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
use seichiassist; | ||
|
||
-- MySQLのスロークエリを引いた結果遅かったSELECTのクエリに対してINDEXを貼るようにする。 | ||
ALTER TABLE playerdata ADD INDEX index_playerdata_playtick(playtick); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 7 additions & 6 deletions
13
src/main/scala/com/github/unchama/seichiassist/subsystems/discordnotification/System.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
package com.github.unchama.seichiassist.subsystems.discordnotification | ||
|
||
import cats.effect.{ContextShift, Sync} | ||
import com.github.unchama.seichiassist.SeichiAssist | ||
import cats.effect.{ContextShift, LiftIO, Sync} | ||
import com.github.unchama.seichiassist.meta.subsystem.Subsystem | ||
import com.github.unchama.seichiassist.subsystems.discordnotification.infrastructure.WebhookDiscordNotificationSender | ||
import com.github.unchama.seichiassist.subsystems.discordnotification.infrastructure.{DefaultDiscordNotificationSender, WebhookDiscordNotificationSender} | ||
import io.chrisdavenport.log4cats.Logger | ||
|
||
trait System[F[_]] extends Subsystem[F] { | ||
implicit val globalNotification: DiscordNotificationAPI[F] | ||
} | ||
|
||
object System { | ||
def wired[F[_] : Sync : ContextShift](configuration: SystemConfiguration): System[F] = new System[F] { | ||
implicit override val globalNotification: DiscordNotificationAPI[F] = | ||
new WebhookDiscordNotificationSender[F](configuration.webhookUrl) | ||
def wired[F[_] : Sync : ContextShift : Logger : LiftIO](configuration: SystemConfiguration): System[F] = new System[F] { | ||
implicit override val globalNotification: DiscordNotificationAPI[F] = { | ||
WebhookDiscordNotificationSender.tryCreate(configuration.webhookUrl).getOrElse(new DefaultDiscordNotificationSender) | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...sist/subsystems/discordnotification/infrastructure/DefaultDiscordNotificationSender.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.github.unchama.seichiassist.subsystems.discordnotification.infrastructure | ||
|
||
import cats.effect.LiftIO | ||
import com.github.unchama.seichiassist.SeichiAssist | ||
import com.github.unchama.seichiassist.subsystems.discordnotification.DiscordNotificationAPI | ||
import io.chrisdavenport.log4cats.Logger | ||
|
||
/** | ||
* この実装は[[send]]が呼ばれるたびに警告をロガーに流す以外は何もしない。 | ||
*/ | ||
final class DefaultDiscordNotificationSender[F[_]: Logger: LiftIO] extends DiscordNotificationAPI[F] { | ||
override def send(message: String): F[Unit] = { | ||
SeichiAssist.instance.loggerF.warn("Discordへの送信が試みられましたが、URLが無効、もしくは与えられていません。コンフィグを確認してください。").to | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/test/scala/com/github/unchama/generic/MapExtraSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.github.unchama.generic | ||
|
||
import org.scalatest.wordspec.AnyWordSpec | ||
|
||
class MapExtraSpec extends AnyWordSpec { | ||
"fillOnBaseSet" should { | ||
"return empty Map" in { | ||
assert(MapExtra.fillOnBaseSet[String, Int](Map(), Set(), 1).isEmpty) | ||
} | ||
|
||
"fail if map's key is not sub-set of set" in { | ||
assertThrows[IllegalArgumentException] { | ||
MapExtra.fillOnBaseSet[String, Int](Map("a" -> 2), Set(), 1) | ||
} | ||
} | ||
|
||
"return filled Map" in { | ||
assert( | ||
MapExtra.fillOnBaseSet( | ||
Map("a" -> 1, "b" -> 2, "c" -> 3), | ||
Set("a", "b", "c", "d"), | ||
4 | ||
) == Map("a" -> 1, "b" -> 2, "c" -> 3, "d" -> 4) | ||
) | ||
} | ||
|
||
"return filled Map when given Map is empty" in { | ||
assert( | ||
MapExtra.fillOnBaseSet( | ||
Map(), | ||
Set("A", "B", "C", "D"), | ||
42 | ||
) == Map("A" -> 42, "B" -> 42, "C" -> 42, "D" -> 42) | ||
) | ||
} | ||
|
||
|
||
} | ||
} |