Skip to content

Commit

Permalink
[DVRL-10] Ensure history uses track activity model (#7678)
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondjacobson authored Feb 22, 2024
1 parent 3a8b27a commit 21f5d8e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
22 changes: 17 additions & 5 deletions packages/discovery-provider/src/api/v1/models/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,28 @@ def format(self, value):
},
)

library_track_activity_model_full = ns.clone(
track_activity_model = ns.model(
"track_activity",
{
"timestamp": fields.String(allow_null=True),
"item_type": fields.FormattedString("track"),
"item": fields.Nested(track),
},
)

track_activity_model_full = ns.model(
"track_activity_full",
activity_model_full,
{"item_type": fields.FormattedString("track"), "item": fields.Nested(track_full)},
{
"timestamp": fields.String(allow_null=True),
"item_type": fields.FormattedString("track"),
"item": fields.Nested(track_full),
},
)

library_collection_activity_model_full = ns.clone(
collection_activity_model_full = ns.model(
"collection_activity_full",
activity_model_full,
{
"timestamp": fields.String(allow_null=True),
"item_type": fields.FormattedString("playlist"),
"item": fields.Nested(full_playlist_without_tracks_model),
},
Expand Down
17 changes: 10 additions & 7 deletions packages/discovery-provider/src/api/v1/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@
from src.api.v1.models.activities import (
activity_model,
activity_model_full,
library_collection_activity_model_full,
library_track_activity_model_full,
collection_activity_model_full,
track_activity_model,
track_activity_model_full,
)
from src.api.v1.models.common import favorite
from src.api.v1.models.developer_apps import authorized_app, developer_app
Expand Down Expand Up @@ -764,13 +765,13 @@ def get(self, id):
track_library_full_response = make_full_response(
"track_library_response_full",
full_ns,
fields.List(fields.Nested(library_track_activity_model_full)),
fields.List(fields.Nested(track_activity_model_full)),
)

collection_library_full_response = make_full_response(
"collection_library_response_full",
full_ns,
fields.List(fields.Nested(library_collection_activity_model_full)),
fields.List(fields.Nested(collection_activity_model_full)),
)


Expand Down Expand Up @@ -990,11 +991,13 @@ def get(self, id):
return success_response(favorites)


history_response = make_full_response(
"history_response", ns, fields.List(fields.Nested(activity_model))
history_response = make_response(
"history_response", ns, fields.List(fields.Nested(track_activity_model))
)
history_response_full = make_full_response(
"history_response_full", full_ns, fields.List(fields.Nested(activity_model_full))
"history_response_full",
full_ns,
fields.List(fields.Nested(track_activity_model_full)),
)

USER_HISTORY_TRACKS_ROUTE = "/<string:id>/history/tracks"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
*/

import { exists, mapValues } from '../runtime';
import type { ActivityFull } from './ActivityFull';
import type { TrackActivityFull } from './TrackActivityFull';
import {
ActivityFullFromJSON,
ActivityFullFromJSONTyped,
ActivityFullToJSON,
} from './ActivityFull';
TrackActivityFullFromJSON,
TrackActivityFullFromJSONTyped,
TrackActivityFullToJSON,
} from './TrackActivityFull';
import type { VersionMetadata } from './VersionMetadata';
import {
VersionMetadataFromJSON,
Expand Down Expand Up @@ -77,10 +77,10 @@ export interface HistoryResponseFull {
version: VersionMetadata;
/**
*
* @type {Array<ActivityFull>}
* @type {Array<TrackActivityFull>}
* @memberof HistoryResponseFull
*/
data?: Array<ActivityFull>;
data?: Array<TrackActivityFull>;
}

/**
Expand Down Expand Up @@ -116,7 +116,7 @@ export function HistoryResponseFullFromJSONTyped(json: any, ignoreDiscriminator:
'signature': json['signature'],
'timestamp': json['timestamp'],
'version': VersionMetadataFromJSON(json['version']),
'data': !exists(json, 'data') ? undefined : ((json['data'] as Array<any>).map(ActivityFullFromJSON)),
'data': !exists(json, 'data') ? undefined : ((json['data'] as Array<any>).map(TrackActivityFullFromJSON)),
};
}

Expand All @@ -136,7 +136,7 @@ export function HistoryResponseFullToJSON(value?: HistoryResponseFull | null): a
'signature': value.signature,
'timestamp': value.timestamp,
'version': VersionMetadataToJSON(value.version),
'data': value.data === undefined ? undefined : ((value.data as Array<any>).map(ActivityFullToJSON)),
'data': value.data === undefined ? undefined : ((value.data as Array<any>).map(TrackActivityFullToJSON)),
};
}

0 comments on commit 21f5d8e

Please sign in to comment.