Skip to content

Commit

Permalink
fix empty content (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
makeevrserg authored Nov 1, 2024
1 parent 68490a5 commit 9ceea4c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.parallel=true
makeevrserg.project.name=IRDBBackend
makeevrserg.project.url=https://github.com/flipperdevices/IRDB-Backend
makeevrserg.project.group=com.flipperdevices.ifrmvp.backend
makeevrserg.project.version.string=0.7.1
makeevrserg.project.version.string=0.7.2
makeevrserg.project.description=Api for IfrSample
makeevrserg.project.developers=makeevrserg|Makeev Roman|[email protected]
# Java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import com.flipperdevices.ifrmvp.backend.model.SignalResponse
import com.flipperdevices.ifrmvp.backend.model.SignalResponseModel
import com.flipperdevices.ifrmvp.backend.route.signal.data.CategoryConfigRepository
import com.flipperdevices.ifrmvp.backend.route.signal.data.IRDBCategoryConfigRepository
import com.flipperdevices.ifrmvp.generator.config.device.api.DeviceKeyNamesProvider
import com.flipperdevices.ifrmvp.generator.config.device.api.DeviceKeyNamesProvider.Companion.getKey
import com.flipperdevices.ifrmvp.generator.config.device.api.any.AnyDeviceKeyNamesProvider
import com.flipperdevices.ifrmvp.model.IfrKeyIdentifier
Expand Down Expand Up @@ -302,7 +301,46 @@ internal class SignalRouteRegistry(
println("#root includedInfraredFilesCount=$includedInfraredFilesCount")
when (includedInfraredFilesCount) {
0L -> {
context.respond(HttpStatusCode.NoContent)
if (signalRequestModel.failedResults.isEmpty()
.and(signalRequestModel.successResults.isEmpty())
.and(signalRequestModel.skippedResults.isEmpty())
) {
println("#root everything is empty")
context.respond(HttpStatusCode.NoContent)
} else {
val fallbackIncludedFileId = transaction(database) {
getIncludedFileIds(
signalRequestModel = when {
signalRequestModel.skippedResults.isNotEmpty() -> {
signalRequestModel.copy(
skippedResults = signalRequestModel.skippedResults.dropLast(1)
)
}

signalRequestModel.failedResults.isNotEmpty() -> {
signalRequestModel.copy(
failedResults = signalRequestModel.failedResults.dropLast(1)
)
}

else -> {
signalRequestModel.copy(
successResults = signalRequestModel.successResults.dropLast(1)
)
}
},
brandId = brand.id
).map { it[InfraredFileTable.id] }.firstOrNull()?.value
}
println("#root fallbackIncludedFileId is $fallbackIncludedFileId")
if (fallbackIncludedFileId == null) {
context.respond(HttpStatusCode.NoContent)
} else {
val response =
SignalResponseModel(ifrFileModel = tableDao.ifrFileById(fallbackIncludedFileId))
context.respond(response)
}
}
return@post
}

Expand Down

0 comments on commit 9ceea4c

Please sign in to comment.