"""Participants Schema.""" from marshmallow import fields from analytics.schemas.common import ( BaseSchema, StreamBreakdownItemSchema, StreamsStoresSchema, ) class ParticipantMetricSchema(BaseSchema): """Marshmallow schema for the metrics in a list of participant metrics.""" id = fields.String() # noqa streams_1_day = fields.Integer() growth_percentage_1_day = fields.Float(data_key="growth_percentage_1_day") streams_7_days = fields.Integer() growth_percentage_7_days = fields.Float(data_key="growth_percentage_7_days") streams_28_days = fields.Integer() growth_percentage_28_days = fields.Float(data_key="growth_percentage_28_days") streams_183_days = fields.Integer() growth_percentage_183_days = fields.Float(data_key="growth_percentage_183_days") streams_365_days = fields.Integer() growth_percentage_365_days = fields.Float(data_key="growth_percentage_365_days") streams_all_time = fields.Integer() class ParticipantMetricsSchema(BaseSchema): """Marshmallow schema for the list of participant metrics.""" metrics = fields.Nested(nested=ParticipantMetricSchema, many=True) total_participants = fields.Integer() class ParticipantStreamsAllSchema(BaseSchema): """Marshmallow schema for participant track-streams-all.""" global_participant_id = fields.String() items = fields.Nested(StreamBreakdownItemSchema, many=True) class ParticipantStreamsStoreSchema(BaseSchema): """Marshmallow schema for participant track-streams-store.""" global_participant_id = fields.String() stores = fields.Nested(StreamsStoresSchema, many=True) class ParticipantSummaryItemSchema(BaseSchema): """Schema for analytics summary item.""" id = fields.String() # noqa: A003 streams = fields.Integer() skips = fields.Integer() saves = fields.Integer() downloads = fields.Integer() track_downloads = fields.Integer() album_downloads = fields.Integer() skip_rate = fields.Float() streams_start_date = fields.Date() streams_end_date = fields.Date() downloads_start_date = fields.Date() downloads_end_date = fields.Date() class ParticipantTimeseriesItemSchema(BaseSchema): """Schema for analytics timeseries item.""" id = fields.String() # noqa: A003 value = fields.Integer() skips = fields.Integer() saves = fields.Integer() skip_rate = fields.Float() date = fields.Date() class ParticipantSummarySchema(BaseSchema): """Marshmallow schema for participant summary.""" items = fields.Nested(ParticipantSummaryItemSchema, many=True) class ParticipantTimeseriesSchema(BaseSchema): """Marshmallow schema for participant timeseries.""" items = fields.Nested(ParticipantTimeseriesItemSchema, many=True)