@@ 315-335 (lines=21) @@ | ||
312 | ||
313 | # Returns an array of tuples where the first item is a millisecond timestamp, |
|
314 | # the next is the total amount of debt, and the next is the total amount |
|
315 | # of stored money for users. |
|
316 | @classmethod |
|
317 | def get_balance_total_daily(cls): |
|
318 | rows = DBSession.query(cls.amount, |
|
319 | cls.type, |
|
320 | cls.to_account_virt_id, |
|
321 | cls.fr_account_virt_id, |
|
322 | event.Event.timestamp)\ |
|
323 | .join(event.Event)\ |
|
324 | .filter(event.Event.deleted==False)\ |
|
325 | .filter(or_( |
|
326 | cls.type=='purchase', |
|
327 | cls.type=='cashdeposit', |
|
328 | cls.type=='ccdeposit', |
|
329 | cls.type=='btcdeposit', |
|
330 | cls.type=='adjustment' |
|
331 | ))\ |
|
332 | .order_by(event.Event.timestamp)\ |
|
333 | .all() |
|
334 | return utility.timeseries_balance_total_daily(rows) |
|
335 | ||
336 | ||
337 | @classmethod |
|
338 | def get_transactions_over_time_for_user(cls, user): |
|
@@ 386-401 (lines=16) @@ | ||
383 | or_( |
|
384 | Transaction.to_account_virt_id == self.id, |
|
385 | Transaction.fr_account_virt_id == self.id, |
|
386 | Transaction.to_account_cash_id == self.id, |
|
387 | Transaction.fr_account_cash_id == self.id), |
|
388 | and_( |
|
389 | or_(event.Event.type == "purchase", |
|
390 | event.Event.type == "deposit"), |
|
391 | event.Event.user_id == self.id)))\ |
|
392 | .filter(event.Event.deleted==False)\ |
|
393 | .order_by(desc(event.Event.timestamp))\ |
|
394 | ||
395 | @limitable_all |
|
396 | def __get_transactions(self): |
|
397 | return __get_transactions_query(self) |
|
398 | ||
399 | @property |
|
400 | def __transactions(self): |
|
401 | return __get_transactions(self) |
|
402 | ||
403 | account.Account.get_transactions_query = __get_transactions_query |
|
404 | account.Account.get_transactions = __get_transactions |