Mercurial > prosody-hg
comparison plugins/mod_storage_internal.lua @ 9105:e735c9865f42
mod_storage_internal: Only apply truncate if there are more items than requested
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 04 Aug 2018 15:44:38 +0200 |
| parents | 469afa02947b |
| children | f76bd399267c 8fcd46ee9bf5 |
comparison
equal
deleted
inserted
replaced
| 9104:e1ca373a7e09 | 9105:e735c9865f42 |
|---|---|
| 189 if query["end"] then | 189 if query["end"] then |
| 190 items:filter(function (item) | 190 items:filter(function (item) |
| 191 return item.when > query["end"]; | 191 return item.when > query["end"]; |
| 192 end); | 192 end); |
| 193 end | 193 end |
| 194 if query.truncate then | 194 if query.truncate and #items > query.truncate then |
| 195 if query.reverse then | 195 if query.reverse then |
| 196 -- Before: { 1, 2, 3, 4, 5, } | 196 -- Before: { 1, 2, 3, 4, 5, } |
| 197 -- After: { 1, 2, 3 } | 197 -- After: { 1, 2, 3 } |
| 198 for i = #items, query.truncate + 1, -1 do | 198 for i = #items, query.truncate + 1, -1 do |
| 199 items[i] = nil; | 199 items[i] = nil; |
