-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrap database job with spring scheduler
- Loading branch information
Showing
16 changed files
with
132 additions
and
137 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -9,4 +9,3 @@ | |
|
||
rootProject.name = "coding-problems-bot" | ||
include("telegram-bot") | ||
include("app-db") |
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
18 changes: 1 addition & 17 deletions
18
telegram-bot/src/main/kotlin/by/jprof/coding/problems/bot/App.kt
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
33 changes: 25 additions & 8 deletions
33
telegram-bot/src/main/kotlin/by/jprof/coding/problems/bot/domain/domain.kt
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,22 +1,39 @@ | ||
package by.jprof.coding.problems.bot.domain | ||
|
||
import org.springframework.data.annotation.Id | ||
import org.springframework.data.domain.Persistable | ||
import org.springframework.data.relational.core.mapping.Table | ||
import java.util.* | ||
|
||
|
||
class Platforms { | ||
companion object { | ||
const val LEETCODE = "Leetcode" | ||
} | ||
enum class Platform(val platform: String) { | ||
LEETCODE("Leetcode") | ||
} | ||
|
||
enum class Messenger(val messenger: String) { | ||
TELEGRAM("Telegram") | ||
} | ||
|
||
@Table | ||
data class Problem( | ||
@Id | ||
val id: String, | ||
@Id @JvmField var id: String, | ||
val link: String, | ||
val title: String, | ||
val acceptance: Float?, | ||
val acceptance: String?, | ||
val difficulty: String, | ||
val platform: String = Platforms.LEETCODE | ||
val platform: String = Platform.LEETCODE.platform | ||
) : Persistable<String> { | ||
override fun getId(): String = id | ||
|
||
override fun isNew(): Boolean { | ||
val new = id.isEmpty() | ||
id = if (new) UUID.randomUUID().toString() else id | ||
return new | ||
} | ||
|
||
} | ||
|
||
data class Chat( | ||
val id: String, | ||
val messenger: String = Messenger.TELEGRAM.messenger | ||
) |
7 changes: 7 additions & 0 deletions
7
telegram-bot/src/main/kotlin/by/jprof/coding/problems/bot/ext/tgbotapi.kt
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,7 @@ | ||
package by.jprof.coding.problems.bot.ext | ||
|
||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage | ||
import dev.inmo.tgbotapi.types.message.abstracts.Message | ||
import dev.inmo.tgbotapi.types.message.content.TextContent | ||
|
||
val Message.text get() = ((this as? ContentMessage<*>)?.content as? TextContent)?.text |
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
5 changes: 5 additions & 0 deletions
5
telegram-bot/src/main/kotlin/by/jprof/coding/problems/bot/projection/projection.kt
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,5 @@ | ||
package by.jprof.coding.problems.bot.projection | ||
|
||
interface ProblemLink { | ||
fun getLink(): String | ||
} |
6 changes: 5 additions & 1 deletion
6
telegram-bot/src/main/kotlin/by/jprof/coding/problems/bot/repository/ProblemRepository.kt
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,6 +1,10 @@ | ||
package by.jprof.coding.problems.bot.repository | ||
|
||
import by.jprof.coding.problems.bot.domain.Problem | ||
import by.jprof.coding.problems.bot.projection.ProblemLink | ||
import kotlinx.coroutines.flow.Flow | ||
import org.springframework.data.repository.kotlin.CoroutineCrudRepository | ||
|
||
interface ProblemRepository : CoroutineCrudRepository<Problem, String> | ||
interface ProblemRepository : CoroutineCrudRepository<Problem, String> { | ||
fun findAllProjectedBy() : Flow<ProblemLink> | ||
} |
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
Oops, something went wrong.