Skip to content

Commit

Permalink
Fix problem pruning message which has readings associated
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncoles committed Oct 6, 2024
1 parent f44569c commit a61cc61
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def prune
# Delete messages not included in kept_messages
mqtt_messages.each do |message|
unless kept_messages.include?(message.id)
# Remove associated readings first
message.readings.destroy_all
# And then remove the message itself
message.destroy
end
end
Expand Down

0 comments on commit a61cc61

Please sign in to comment.