mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-24 14:35:45 +00:00
fix get_assets issue (#160)
* adjusted get_assets and from_db for tarantool Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added comment Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
14601b0f25
commit
dac65d6753
@ -168,10 +168,13 @@ def get_asset(connection, asset_id: str):
|
|||||||
def get_assets(connection, assets_ids: list) -> list:
|
def get_assets(connection, assets_ids: list) -> list:
|
||||||
_returned_data = []
|
_returned_data = []
|
||||||
for _id in list(set(assets_ids)):
|
for _id in list(set(assets_ids)):
|
||||||
asset = get_asset(connection, _id)
|
res = connection.run(
|
||||||
_returned_data.append(asset)
|
connection.space("assets").select(_id, index="txid_search")
|
||||||
|
)
|
||||||
|
_returned_data.append(res[0])
|
||||||
|
|
||||||
return sorted(_returned_data, key=lambda k: k["id"], reverse=False)
|
sorted_assets = sorted(_returned_data, key=lambda k: k[1], reverse=False)
|
||||||
|
return [(json.loads(asset[0]), asset[1]) for asset in sorted_assets]
|
||||||
|
|
||||||
|
|
||||||
@register_query(TarantoolDBConnection)
|
@register_query(TarantoolDBConnection)
|
||||||
|
|||||||
@ -693,8 +693,9 @@ class Transaction(object):
|
|||||||
assets = list(planet.get_assets(tx_ids))
|
assets = list(planet.get_assets(tx_ids))
|
||||||
for asset in assets:
|
for asset in assets:
|
||||||
if asset is not None:
|
if asset is not None:
|
||||||
|
# This is tarantool specific behaviour needs to be addressed
|
||||||
tx = tx_map[asset[1]]
|
tx = tx_map[asset[1]]
|
||||||
tx['asset'] = asset
|
tx['asset'] = asset[0]
|
||||||
|
|
||||||
tx_ids = list(tx_map.keys())
|
tx_ids = list(tx_map.keys())
|
||||||
metadata_list = list(planet.get_metadata(tx_ids))
|
metadata_list = list(planet.get_metadata(tx_ids))
|
||||||
|
|||||||
@ -58,7 +58,7 @@ def test_write_assets(db_conn):
|
|||||||
documents = query.get_assets(assets_ids=[asset["id"] for asset in assets], connection=db_conn)
|
documents = query.get_assets(assets_ids=[asset["id"] for asset in assets], connection=db_conn)
|
||||||
|
|
||||||
assert len(documents) == 3
|
assert len(documents) == 3
|
||||||
assert list(documents)[0] == assets[:-1][0]
|
assert list(documents)[0][0] == assets[:-1][0]
|
||||||
|
|
||||||
|
|
||||||
def test_get_assets(db_conn):
|
def test_get_assets(db_conn):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user