Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #250 from Z-Jais/master
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
Ziedelth authored Feb 19, 2024
2 parents c9b477d + 57c32e6 commit d54b2a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<description>api</description>

<properties>
<ktor_version>2.3.7</ktor_version>
<ktor_version>2.3.8</ktor_version>
<kotlin.code.style>official</kotlin.code.style>
<kotlin.version>1.9.22</kotlin.version>
<kotlin.compiler.languageVersion>2.0</kotlin.compiler.languageVersion>
Expand All @@ -18,8 +18,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
<main.class>fr.ziedelth.ApplicationKt</main.class>
<junit-jupiter.version>5.10.1</junit-jupiter.version>
<hibernate.version>6.4.2.Final</hibernate.version>
<junit-jupiter.version>5.10.2</junit-jupiter.version>
<hibernate.version>6.4.4.Final</hibernate.version>

<sonar.coverage.exclusions>
**/fr/ziedelth/dtos/**,
Expand Down
21 changes: 1 addition & 20 deletions src/main/kotlin/fr/ziedelth/controllers/CalendarController.kt
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
package fr.ziedelth.controllers

import com.google.inject.Inject
import fr.ziedelth.dtos.CalendarDto
import fr.ziedelth.events.CalendarReleaseEvent
import fr.ziedelth.events.RecommendationEvent
import fr.ziedelth.repositories.AnimeRepository
import fr.ziedelth.services.RecommendationService
import fr.ziedelth.utils.plugins.PluginManager
import fr.ziedelth.utils.routes.Authorized
import fr.ziedelth.utils.routes.BodyParam
import fr.ziedelth.utils.routes.Path
import fr.ziedelth.utils.routes.Response
import fr.ziedelth.utils.routes.method.Post
import io.ktor.http.*
import java.time.Duration

class CalendarController : AbstractController<CalendarDto>("/calendar") {
@Inject
private lateinit var animeRepository: AnimeRepository

@Inject
private lateinit var recommendationService: RecommendationService

@Path
@Post
@Authorized
Expand All @@ -30,15 +19,7 @@ class CalendarController : AbstractController<CalendarDto>("/calendar") {
return Response(HttpStatusCode.BadRequest, MISSING_PARAMETERS_MESSAGE_ERROR)
}

Thread {
PluginManager.callEvent(CalendarReleaseEvent(calendarDto))
Thread.currentThread().join(Duration.ofHours(3).toMillis())

val randomAnime = animeRepository.getAll().random()
val recommendations = recommendationService.getRecommendations(listOf(randomAnime))
PluginManager.callEvent(RecommendationEvent(randomAnime, recommendations))
}.start()

PluginManager.callEvent(CalendarReleaseEvent(calendarDto))
return Response.created(calendarDto)
}
}

0 comments on commit d54b2a5

Please sign in to comment.