Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix empty content #17

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading