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

Commit

Permalink
Disable RecommendationEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziedelth committed Feb 19, 2024
1 parent ffaad81 commit 57c32e6
Showing 1 changed file with 1 addition and 20 deletions.
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 57c32e6

Please sign in to comment.