From 91abe5eb99ff471fe981e3b2479341321b68fcd7 Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Tue, 16 Jan 2018 11:51:12 +0100 Subject: fix off-by-one /history error --- talerbank/app/views.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/talerbank/app/views.py b/talerbank/app/views.py index 62f76b1..d5ad6fe 100644 --- a/talerbank/app/views.py +++ b/talerbank/app/views.py @@ -425,7 +425,9 @@ def login_via_headers(view_func): # 'delta': how many results are going to be extracted. If 'None' # is given, no filter of this kind will be applied. # 'start': a "id" indicating the first record to be returned. -# If -1 is given, then the first record will be the youngest. +# If -1 is given, then the first record will be the youngest +# and 'delta' records will be returned, _regardless_ of the +# 'sign' being passed. # 'sign': (+|-) indicating that we want records younger|older # than 'start'. @@ -443,15 +445,11 @@ def query_history(bank_account, direction, delta, start, sign): sign_filter = { "+": Q(id__gt=start), "-": Q(id__lt=start), - "*": Q(), - "x": not Q(), } # Handle special case. - if start == -1: # can only retrieve older records. - sign = "*" - if sign == "+": # no result is younger than the youngest. - sign = "x" + if start == -1: # return 'delta' youngest records. + sign = "+" return BankTransaction.objects.filter( direction_switch.get(direction), -- cgit v1.2.3