Skip to content

Commit

Permalink
Merge pull request #432 from lunatech-labs/fix-automatiic-scheduling-bug
Browse files Browse the repository at this point in the history
Fix bug where deleted recurrent schedules where still being automatically created
  • Loading branch information
leo-bogastry authored Sep 8, 2023
2 parents 853b3a1 + f0e26cf commit eb0a619
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.ktorm.dsl.map
import org.ktorm.dsl.select
import org.ktorm.dsl.update
import org.ktorm.dsl.where
import org.ktorm.schema.ColumnDeclaring
import java.time.LocalDate
import java.util.UUID

Expand All @@ -24,8 +25,13 @@ class RecurrentSchedulesService(val database: Database) {

fun getIntervalDate(fromDate: LocalDate, toDate: LocalDate): List<RecurrentSchedule> =
database.from(RecurrentSchedules).select()
.where { (RecurrentSchedules.isDeleted eq false) }
.where { (RecurrentSchedules.nextDate greater fromDate) and (RecurrentSchedules.nextDate lessEq toDate) }
.where {
val conditions = ArrayList<ColumnDeclaring<Boolean>>()
conditions += RecurrentSchedules.isDeleted eq false
conditions += RecurrentSchedules.nextDate greater fromDate
conditions += RecurrentSchedules.nextDate lessEq toDate
conditions.reduce { a, b -> a and b }
}
.map { RecurrentSchedules.createEntity(it) }

fun getByUuid(uuid: UUID): List<RecurrentSchedule> =
Expand Down
2 changes: 0 additions & 2 deletions src/main/com/lunatech/chef/api/routes/Authorization.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ fun Routing.authentication(usersService: UsersService, admins: List<String>) {
fun addUserToDB(usersService: UsersService, payload: Payload): User {
val email = payload.getClaim("email").asString()

logger.info("user {} logged in", email)

val user = usersService.getByEmailAddress(email)
val name = getUserNameFromEmail(email)

Expand Down

0 comments on commit eb0a619

Please sign in to comment.