Skip to content

Commit

Permalink
edit json schema
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacsolo committed Aug 12, 2022
1 parent e864f2c commit 66a6ada
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 27 deletions.
1 change: 0 additions & 1 deletion discovery-provider/src/api/v1/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def get(self, playlist_id):
args = current_user_parser.parse_args()
current_user_id = get_current_user_id(args)
playlist = get_playlist(playlist_id, current_user_id)
logger.info(f"asdf playlist {playlist}")
if playlist:
tracks = get_tracks_for_playlist(playlist_id, current_user_id)
playlist["tracks"] = tracks
Expand Down
1 change: 0 additions & 1 deletion discovery-provider/src/queries/get_playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def get_unpopulated_playlists():
key = make_cache_key(args)

(playlists, playlist_ids) = get_unpopulated_playlists()
logger.info(f"asdf unpopulated playlists {playlists}")
# bundle peripheral info into playlist results
playlists = populate_playlist_metadata(
session,
Expand Down
2 changes: 1 addition & 1 deletion discovery-provider/src/tasks/entity_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,5 +444,5 @@ def process_playlist_data_event(
playlist_record.metadata_multihash = metadata_cid

logger.info(
f"asdf index.py | AudiusData | Updated playlist record {playlist_record}"
f"index.py | AudiusData | Updated playlist record {playlist_record}"
)
2 changes: 1 addition & 1 deletion discovery-provider/src/tasks/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ def index_blocks(self, db, blocks_list):
session.commit()
metric.save_time({"scope": "commit_time"}, start_time=commit_start_time)
logger.info(
f"asdf index.py | session committed to db for block={block_number} in {time.time() - commit_start_time}s"
f"index.py | session committed to db for block={block_number} in {time.time() - commit_start_time}s"
)
except Exception as e:
# Use 'commit' as the tx hash here.
Expand Down
3 changes: 0 additions & 3 deletions discovery-provider/src/utils/redis_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def use_redis_cache(key, ttl_sec, work_func):
redis = redis_connection.get_redis()
cached_value = get_json_cached_key(redis, key)
if cached_value:
logger.info(f"asdf use redis cache {cached_value}")
return cached_value
to_cache = work_func()
set_json_cached_key(redis, key, to_cache, ttl_sec)
Expand Down Expand Up @@ -145,7 +144,6 @@ def inner_wrap(*args, **kwargs):
if cached_resp:
if transform is not None:
return transform(cached_resp)
logger.info(f"asdf get cached response {cached_resp}")

return cached_resp, 200

Expand All @@ -155,7 +153,6 @@ def inner_wrap(*args, **kwargs):
resp, status_code = response
if status_code < 400:
set_json_cached_key(redis, key, resp, ttl_sec)
logger.info(f"asdf get non cached response {resp}")

return resp, status_code
set_json_cached_key(redis, key, response, ttl_sec)
Expand Down
18 changes: 0 additions & 18 deletions libs/src/api/entityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ export interface PlaylistOperationResponse {

const { encodeHashId, decodeHashId } = Utils

// Minimum playlist ID, intentionally higher than legacy playlist ID range
const MIN_PLAYLIST_ID = 400000
// Maximum playlist ID, reflects postgres max integer value
const MAX_PLAYLIST_ID = 2147483647

type PlaylistTrackId = { time: number; track: number; metadata_time?: number }

type PlaylistContents = {
Expand Down Expand Up @@ -328,7 +323,6 @@ export class EntityManager extends Base {
this.REQUIRES(Services.CREATOR_NODE)

const playlist = await this.getFullPlaylist(playlistId, userId)
console.log('asdf existing playlist', playlist)

const updatedPlaylistTracks = this.mapAddedTimestamps(
playlist.added_timestamps
Expand Down Expand Up @@ -399,7 +393,6 @@ export class EntityManager extends Base {
const entityType = EntityType.PLAYLIST
this.REQUIRES(Services.CREATOR_NODE)
const playlist = await this.getFullPlaylist(playlistId, userId)
console.log('asdf existing playlist', playlist)

const existingPlaylistTracks = this.mapAddedTimestamps(
playlist.added_timestamps
Expand Down Expand Up @@ -472,9 +465,7 @@ export class EntityManager extends Base {
const updateAction = Action.UPDATE
const entityType = EntityType.PLAYLIST
this.REQUIRES(Services.CREATOR_NODE)
console.log('asdf get full playlist ', { playlistId, userId })
const playlist = await this.getFullPlaylist(playlistId, userId)
console.log('asdf existing playlist', playlist)

const existingPlaylistTracks = this.mapAddedTimestamps(
playlist.added_timestamps
Expand Down Expand Up @@ -552,14 +543,6 @@ export class EntityManager extends Base {
let error = null
let resp: any
try {
console.log('asdf managing entity', {
userId,
entityType,
entityId,
action,
metadataMultihash
})

resp = await this.contracts.EntityManagerClient?.manageEntity(
userId,
entityType,
Expand All @@ -571,7 +554,6 @@ export class EntityManager extends Base {
return { txReceipt: resp.txReceipt, error }
} catch (e) {
error = (e as Error).message
console.log('asdf manageEntity error', error)
return { txReceipt: null, error }
}
}
Expand Down
18 changes: 16 additions & 2 deletions libs/src/services/schemaValidator/schemas/playlistSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
"default": null
},
"playlist_contents": {
"type": ["array", "null"],
"default": []
"type": "object",
"$ref": "#/definitions/PlaylistContents",
"default": {
"track_ids": []
}
},
"playlist_name": {
"type": ["string", "null"],
Expand Down Expand Up @@ -51,6 +54,17 @@
"maxLength": 46,
"pattern": "^Qm[a-zA-Z0-9]{44}$",
"title": "CID"
},
"PlaylistContents": {
"type": "object",
"additionalProperties": false,
"properties": {
"track_ids": {
"type": "array",
"default": []
}
},
"title": "PlaylistContents"
}
}
}

0 comments on commit 66a6ada

Please sign in to comment.