Skip to content

Commit

Permalink
Fix resetting of statistics when no statistic exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomis committed Dec 15, 2019
1 parent 9493b2b commit f9ae34f
Showing 1 changed file with 4 additions and 7 deletions.
Expand Up @@ -82,15 +82,12 @@ class StatisticsTask(private val rooms: String, private val reset: Boolean) : Du
table.deleteItem(hashKeyName, item[hashKeyName]!!.s)
} else {
val values = item.minus(nonStatsItems)
val updateExpression = "SET " + values.entries.joinToString(", ") {
"${it.key} :${it.key}"
}
val valueMap = values.entries.fold(ValueMap()) { r, entry ->
r.withNumber(":" + entry.key, 0)
if (values.isEmpty()) {
return
}
val updateExpression = "REMOVE " + values.keys.joinToString(", ")
val update = UpdateItemSpec().withPrimaryKey(hashKeyName, item[hashKeyName]!!.s)
.withUpdateExpression(updateExpression)
.withValueMap(valueMap)
table.updateItem(update)
}
}
Expand All @@ -100,7 +97,7 @@ class StatisticsTask(private val rooms: String, private val reset: Boolean) : Du
if (reset) {
// Remove all repositories
// Reset statistics on all secrets
scan.items.map(this::resetItem)
scan.items.forEach(this::resetItem)
}
return listOf("***RELOAD!***").plus(scan.items.mapNotNull(this::itemToMessage))
}
Expand Down

0 comments on commit f9ae34f

Please sign in to comment.