[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-bank] branch master updated: History element order.
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-bank] branch master updated: History element order. |
Date: |
Thu, 06 Sep 2018 15:15:39 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository bank.
The following commit(s) were added to refs/heads/master by this push:
new 2e90943 History element order.
2e90943 is described below
commit 2e90943de2a8e640e647d39cd59a3063c0146511
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Sep 6 15:11:54 2018 +0200
History element order.
The user can choose the order (ascending/descending)
that history elements are returned in.
This allows to NOT change the current wirewatch logic
and to show puclic accounts histories in a descending
fashion.
---
talerbank/app/tests.py | 6 +++---
talerbank/app/views.py | 32 +++++++++++++++++++++++++-------
2 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index 7c246ec..a3fc291 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -400,12 +400,12 @@ class HistoryTestCase(TestCase):
delta="4", direction="both"),
HistoryContext(
expected_resp={
- "fields": [("row_id", 9)],
+ "fields": [("row_id", 6)],
"status": 200},
delta="+1", start="5", direction="both"),
HistoryContext(
expected_resp={
- "fields": [("wt_subject", "h")],
+ "fields": [("wt_subject", "a")],
"status": 200},
delta="-1", start=9, direction="both"),
HistoryContext(
@@ -600,7 +600,7 @@ class MeasureHistory(TestCase):
# Measure the time extract_history() needs to retrieve
# ~ntransfers records.
timer = timeit.Timer(
- stmt="extract_history(self.user_bankaccount0)",
+ stmt="extract_history(self.user_bankaccount0, False)",
setup="from talerbank.app.views import extract_history",
globals=locals())
total_time = timer.timeit(number=1)
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 6a09edf..1e53d98 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -184,7 +184,8 @@ def profile_page(request):
currency=request.user.bankaccount.amount.currency,
account_no=request.user.bankaccount.account_no,
wt_form=wtf,
- history=extract_history(request.user.bankaccount),
+ history=extract_history(request.user.bankaccount,
+ True),
)
if settings.TALER_SUGGESTED_EXCHANGE:
context["suggested_exchange"] = settings.TALER_SUGGESTED_EXCHANGE
@@ -326,7 +327,11 @@ def logout_view(request):
return redirect("index")
-def extract_history(account, delta=None, start=-1, sign="+"):
+def extract_history(account,
+ descending,
+ delta=None,
+ start=-1,
+ sign="+"):
history = []
qs = query_history(account, "both", delta, start, sign)
for item in qs:
@@ -376,6 +381,7 @@ def serve_public_accounts(request, name=None, page=None):
# Retrieve DELTA records younger than 'start_row' (included).
history = extract_history(user.bankaccount,
+ True,
DELTA * page,
-1,
"+")[DELTA * (page - 1):(DELTA * page)]
@@ -420,11 +426,23 @@ def login_via_headers(view_func):
# 'sign' being passed.
# 'sign': (+|-) indicating that we want records younger|older
# than 'start'.
-
-def query_history(bank_account, direction, delta, start, sign):
- qs = query_history_raw(bank_account, direction, start, sign)
- # '-id' does descending ordering.
- return qs.order_by("-id")[:delta]
+# 'descending': records are sorted older->younger per default,
+# unless this value is true.
+
+def query_history(bank_account,
+ direction,
+ delta,
+ start,
+ sign,
+ descending=False):
+
+ qs = query_history_raw(bank_account,
+ direction,
+ start,
+ sign)
+
+ order = "-id" if descending else "id"
+ return qs.order_by(order)[:delta]
def query_history_raw(bank_account, direction, start, sign):
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-bank] branch master updated: History element order.,
gnunet <=