Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DVRL-10] Ensure history uses track activity model #7678

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)),
};
}