Skip to content

Commit

Permalink
stream subtype
Browse files Browse the repository at this point in the history
  • Loading branch information
wkrzywiec committed Feb 18, 2025
1 parent 2775d8c commit 349bd67
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion services/mankkoo/mankkoo/stream/stream_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ def load_streams(active: bool, type: str) -> list[Stream]:

query = f"""
SELECT
id, type,
id,
CASE
WHEN type = 'account' THEN metadata->>'accountType'
WHEN type = 'investment' THEN metadata->>'category'
WHEN type = 'retirement' THEN metadata->>'accountType'
WHEN type = 'stocks' THEN metadata->>'type'
ELSE type
END AS type
,
CASE
WHEN type = 'account' THEN CONCAT(metadata->>'bankName', ' - ', metadata->>'alias')
WHEN type = 'investment' THEN metadata->>'investmentName'
Expand Down
6 changes: 3 additions & 3 deletions services/mankkoo/tests/controller/stream_controller_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ def test_all_streams_are_listed__if_no_filters_are_provided__and_stream_names_ar
assert len(payload) == 4

account_stream = next(x for x in payload if x['id'] == str(streams[0].id))
assert account_stream['type'] == 'account'
assert account_stream['type'] == 'checking'
assert account_stream['name'] == streams[0].metadata['bankName'] + ' - ' + streams[0].metadata['alias']

investment_stream = next(x for x in payload if x['id'] == str(streams[1].id))
assert investment_stream['type'] == 'investment'
assert investment_stream['type'] == 'treasury_bonds'
assert investment_stream['name'] == streams[1].metadata['investmentName']

retirement_stream = next(x for x in payload if x['id'] == str(streams[2].id))
assert retirement_stream['type'] == 'retirement'
assert retirement_stream['name'] == streams[2].metadata['alias']

etf_stream = next(x for x in payload if x['id'] == str(streams[3].id))
assert etf_stream['type'] == 'stocks'
assert etf_stream['type'] == 'ETF'
assert etf_stream['name'] == streams[3].metadata['etfName']

def test_only_active_streams_are_listed__if_active_qparam_equals_true(test_client):
Expand Down

0 comments on commit 349bd67

Please sign in to comment.