[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-bank] branch master updated: fix history query
From: |
gnunet |
Subject: |
[taler-bank] branch master updated: fix history query |
Date: |
Tue, 03 Dec 2019 17:47:46 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository bank.
The following commit(s) were added to refs/heads/master by this push:
new dedf7f3 fix history query
dedf7f3 is described below
commit dedf7f3ea7c0c8cc660f9784b279ed4002437c02
Author: Florian Dold <address@hidden>
AuthorDate: Tue Dec 3 17:47:41 2019 +0100
fix history query
---
talerbank/app/views.py | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 518a309..5ec770e 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -487,7 +487,6 @@ def logout_view(request):
#
# @param account the bank account object whose history is being
# extracted.
-# @param descending currently not used.
# @param delta how many history entries will be contained in the
# array (will be passed as-is to the internal routine
# @a query_history).
@@ -495,10 +494,8 @@ def logout_view(request):
# value (which is a row ID), and going to the past or to
# the future (depending on the user choice). However, this
# value itself will not be included in the history.
-# @param sign this value ("+"/"-") determines whether the history
-# entries will be younger / older than @a start.
# @return the history array.
-def extract_history(account, delta, start=UINT64_MAX):
+def extract_history(account, delta, start=None):
history = []
qs = query_history(account, "both", delta, start, "descending")
for item in qs:
@@ -678,15 +675,19 @@ def query_history_range(bank_account, direction, start,
end, descending):
# entries will be younger / older than @a start.
# @param ordering "descending" or anything else (for "ascending").
def query_history(bank_account, direction, delta, start, ordering):
- def sign_filter(delta):
- if 0 > delta:
- return Q(id__lt=start)
- return Q(id__gt=start)
+ if start is None:
+ if delta > 0:
+ start = -1
+ else:
+ start = UINT64_MAX
+ if delta < 0:
+ sign_filter = Q(id__lt=start)
+ else:
+ sign_filter = Q(id__gt=start)
qs = BankTransaction.objects.filter(
direction_switch(bank_account, direction), sign_filter(delta)
)
-
order = "-id" if "descending" == ordering else "id"
return qs.order_by(order)[:abs(delta)]
@@ -769,12 +770,11 @@ def serve_history_range(request, user_account):
@login_via_headers
def serve_history(request, user_account):
args = HistoryParams(request.GET.dict())
-
qs = query_history(
user_account.bankaccount,
args.get("direction"),
args.get("delta"),
- args.get("start", UINT64_MAX),
+ args.get("start", None),
args.get("ordering", "descending")
)
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-bank] branch master updated: fix history query,
gnunet <=