Skip to content

Commit

Permalink
Fix multiple files (#13)
Browse files Browse the repository at this point in the history
* try up version

* add file id exclusion

* up version 0.5.1

* add file id exclusion
  • Loading branch information
makeevrserg committed Sep 17, 2024
1 parent 0a3b257 commit 29660a6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 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.5.0
makeevrserg.project.version.string=0.5.1
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 @@ -54,13 +54,21 @@ internal class SignalRouteRegistry(
* order by INFRARED_FILE."signal_count" desc
*/
private fun getIncludedFileIds(signalRequestModel: SignalRequestModel, brandId: Long): Query {
val excludedFileIds = transaction(database) {
InfraredFileToSignalTable.select(InfraredFileToSignalTable.infraredFileId)
.where {
InfraredFileToSignalTable.signalId inList
signalRequestModel.failedResults
.map(SignalRequestModel.SignalResultData::signalId)
}.map { it[InfraredFileToSignalTable.infraredFileId].value }
}
return transaction(database) {
InfraredFileTable
.join(
otherTable = InfraredFileToSignalTable,
onColumn = InfraredFileTable.id,
otherColumn = InfraredFileToSignalTable.infraredFileId,
joinType = JoinType.INNER
joinType = JoinType.LEFT
)
.select(InfraredFileTable.id, InfraredFileTable.signalCount)
.groupBy(InfraredFileTable.id)
Expand All @@ -70,15 +78,29 @@ internal class SignalRouteRegistry(
val successSignalIds = signalRequestModel
.successResults
.map(SignalRequestModel.SignalResultData::signalId)
if (successSignalIds.isNotEmpty()) {
andWhere {
var nextQuery = this
nextQuery = if (successSignalIds.isNotEmpty()) {
nextQuery.andWhere {
InfraredFileToSignalTable
.signalId
.inList(successSignalIds)
}
} else {
this
nextQuery
}
val failedSignalIds = signalRequestModel
.failedResults
.map(SignalRequestModel.SignalResultData::signalId)
nextQuery = if (failedSignalIds.isNotEmpty()) {
nextQuery.andWhere {
InfraredFileToSignalTable
.infraredFileId
.notInList(excludedFileIds)
}
} else {
nextQuery
}
nextQuery
}
}
}
Expand Down Expand Up @@ -119,6 +141,7 @@ internal class SignalRouteRegistry(
.or { SignalKeyTable.hash.eq(identifier.hash) }
}
}

is IfrKeyIdentifier.Name -> {
andWhere {
SignalKeyTable.remoteKeyName.eq(identifier.name)
Expand Down

0 comments on commit 29660a6

Please sign in to comment.