Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rkw committed Jul 13, 2024
1 parent 9261fdc commit 3e1b281
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
25 changes: 21 additions & 4 deletions monzo-search
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ class Monzo:

filter_expression = 'contains(#description, :description)'

attr_names['#description'] = 'description'
attr_values[':description'] = {'S': query_string}
attr_names['#description'] = 'description_search'
attr_values[':description'] = {'S': query_string.lower()}

if query_string.replace('.','').isdigit():
# integer value is queried as a range <n>.00 - <n>.99
Expand All @@ -224,15 +224,15 @@ class Monzo:
attr_values[':zero'] = {'N': '0'}
attr_values[':money_value'] = {'N': query_string}

transactions = Transaction.search(filter_expression=filter_expression, attr_names=attr_names, attr_values=attr_values)
transactions = self.sort_transactions(Transaction.search(filter_expression=filter_expression, attr_names=attr_names, attr_values=attr_values))

# transactions = query.groupBy('`transaction`.id') \
# .orderBy('date, created_at', 'asc') \
# .getall()
#
# transactions = self.process_pending_refunds(transactions)

display_columns = ['id','account','pot','date','money_in','money_out','description']
display_columns = ['account','pot','date','money_in','money_out','description']

if show_declined:
display_columns.append('decline_reason')
Expand Down Expand Up @@ -398,4 +398,21 @@ class Monzo:
return dt


def sort_transactions(self, transactions):
sorted_transactions = []
transactions_by_timestamp = {}

for transaction in transactions:
if transaction.timestamp not in transactions_by_timestamp:
transactions_by_timestamp[transaction.timestamp] = []

transactions_by_timestamp[transaction.timestamp].append(transaction)

for timestamp in sorted(transactions_by_timestamp):
for transaction in transactions_by_timestamp[timestamp]:
sorted_transactions.append(transaction)

return sorted_transactions


Monzo(sys.argv)
2 changes: 1 addition & 1 deletion monzo_utils/lib/db_driver/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def get_columns(self, table, exclude=None):


def put_item(self, table, data):
self.dbd.put_item(
resp = self.dbd.put_item(
TableName=f"{self.prefix}_{table}",
Item=self.to_dbd(data)
)
Expand Down
3 changes: 2 additions & 1 deletion monzo_utils/lib/monzo_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ def add_transaction(self, account, mo_transaction, pot_account_ids, pot_id=None)

if type(mo_transaction.metadata) == dict:
for key in mo_transaction.metadata:
transaction_data[key] = mo_transaction.metadata[key]
if key.split('_')[0] != 'metadata':
transaction_data['metadata_' + key] = mo_transaction.metadata[key]

transaction.update(transaction_data)

Expand Down

0 comments on commit 3e1b281

Please sign in to comment.