[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-bank] branch master updated: New date-range-based hi
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-bank] branch master updated: New date-range-based history extractor function signature. |
Date: |
Tue, 02 Apr 2019 18:57:28 +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 a3f2e32 New date-range-based history extractor function signature.
a3f2e32 is described below
commit a3f2e328a0316fa6d44d225050007f07f7e24c32
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Apr 2 18:56:47 2019 +0200
New date-range-based history extractor function signature.
---
talerbank/app/views.py | 73 +++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 58 insertions(+), 15 deletions(-)
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index fd8ec2a..9249cf3 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -559,9 +559,57 @@ def login_via_headers(view_func):
##
-# Helper function that sorts in a descending, or ascending
-# manner, the history elements returned by the internal routine
-# @a query_history_raw.
+# Build the DB query switch based on the "direction" history
+# argument given by the user.
+#
+# @param bank_account bank account of the user requesting history.
+# @param direction the "direction" URL parameter given by the user.
+# Note: this values got sanity-checked before this function
+# is called.
+def direction_switch(bank_account, direction):
+ direction_switch = {
+ "both": (Q(debit_account=bank_account) |
+ Q(credit_account=bank_account)),
+ "credit": Q(credit_account=bank_account),
+ "debit": Q(debit_account=bank_account),
+ "cancel+": (Q(credit_account=bank_account) &
+ Q(cancelled=True)),
+ "cancel-": (Q(debit_account=bank_account) &
+ Q(cancelled=True)),
+ }
+ return direction_switch.get(direction)
+
+##
+# Main routine querying for histories, based on _date ranges_.
+#
+# @param bank_account the bank account object whose
+# history is being extracted.
+# @param direction takes the following three values,
+# * debit: only entries where the querying user has _paid_
+# will be returned.
+# * credit: only entries where the querying user _got_
+# paid will be returned.
+# * both: both of the cases above will be returned.
+# * cancel+: only entries where the querying user cancelled
+# the _receiving_ of money will be returned.
+# * cancel-: only entries where the querying user cancelled
+# the _paying_ of money will be returned.
+# @param start timestamp of the oldest element allowed in the
+# result.
+# @param end timestamp of the youngest element allowed in the
+# result.
+# @param descending if True, then the results will have the
+# youngest entry in the first position.
+def query_history_range(bank_account,
+ direction,
+ start,
+ end,
+ descending):
+ pass
+
+
+##
+# Main routine querying for histories.
#
# @param bank_account the bank account object whose
# history is being extracted.
@@ -593,24 +641,13 @@ def query_history(bank_account,
sign,
descending=True):
- direction_switch = {
- "both": (Q(debit_account=bank_account) |
- Q(credit_account=bank_account)),
- "credit": Q(credit_account=bank_account),
- "debit": Q(debit_account=bank_account),
- "cancel+": (Q(credit_account=bank_account) &
- Q(cancelled=True)),
- "cancel-": (Q(debit_account=bank_account) &
- Q(cancelled=True)),
- }
-
sign_filter = {
"+": Q(id__gt=start),
"-": Q(id__lt=start),
}
qs = BankTransaction.objects.filter(
- direction_switch.get(direction),
+ direction_switch(bank_account, direction),
sign_filter.get(sign))
order = "-id" if descending else "id"
@@ -674,6 +711,12 @@ def serve_history(request, user_account):
if not start:
start = 0 if "+" == sign else UINT64_MAX
+ # query_history_range (bank_account,
+ # direction,
+ # start,
+ # end,
+ # ordering)
+
qs = query_history(user_account.bankaccount,
request.GET.get("direction"),
int(parsed_delta.group(2)),
--
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: New date-range-based history extractor function signature.,
gnunet <=