Skip to content

Commit

Permalink
Fix last_added_to field for uploaded collections (#3784)
Browse files Browse the repository at this point in the history
* Fix last_added_to field for uploaded collections

* fix test
  • Loading branch information
isaacsolo authored Aug 29, 2022
1 parent e240525 commit d905e1d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ def test_index_valid_playlists(app, mocker):
)
},
],
"CreateAlbumTx": [
{
"args": AttributeDict(
{
"_entityId": PLAYLIST_ID_OFFSET + 3,
"_entityType": "Playlist",
"_userId": 1,
"_action": "Create",
"_metadata": "QmCreateAlbum4",
"_signer": "user1wallet",
}
)
},
],
}

entity_manager_txs = [
Expand Down Expand Up @@ -131,6 +145,13 @@ def get_events_side_effect(_, tx_receipt):
"playlist_image_sizes_multihash": "",
"playlist_name": "playlist 3 updated",
},
"QmCreateAlbum4": {
"playlist_contents": {"track_ids": [{"time": 1660927554, "track": 1}]},
"description": "",
"playlist_image_sizes_multihash": "",
"playlist_name": "album",
"is_album": True,
},
}

entities = {
Expand Down Expand Up @@ -162,7 +183,7 @@ def get_events_side_effect(_, tx_receipt):

# validate db records
all_playlists: List[Playlist] = session.query(Playlist).all()
assert len(all_playlists) == 6
assert len(all_playlists) == 7

playlists_1: List[Playlist] = (
session.query(Playlist)
Expand Down Expand Up @@ -208,6 +229,18 @@ def get_events_side_effect(_, tx_receipt):
assert playlist_3.is_delete == False
assert playlist_3.is_current == True

albums: List[Playlist] = (
session.query(Playlist)
.filter(Playlist.is_current == True, Playlist.is_album == True)
.all()
)
assert len(albums) == 1
album = albums[0]
assert datetime.timestamp(album.last_added_to) == 1585336422
assert album.playlist_name == "album"
assert album.is_delete == False
assert album.is_current == True


def test_index_invalid_playlists(app, mocker):
"Tests invalid batch of playlists create/update/delete actions"
Expand Down
2 changes: 1 addition & 1 deletion discovery-provider/src/tasks/entity_manager/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def create_playlist(params: ManageEntityParameters):
"time": params.block_integer_time,
}
)
last_added_to = params.block_integer_time
last_added_to = params.block_datetime
create_playlist_record = Playlist(
playlist_id=playlist_id,
metadata_multihash=params.metadata_cid,
Expand Down

0 comments on commit d905e1d

Please sign in to comment.