Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • funkwhale funkwhale
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 379
    • Issues 379
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 20
    • Merge requests 20
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • funkwhalefunkwhale
  • funkwhalefunkwhale
  • Merge requests
  • !1312

Fix recently listened widget and simple artist serializer

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Ciarán Ainsworth requested to merge 1446-fix-recently-listened into develop May 05, 2021
  • Overview 4
  • Commits 4
  • Pipelines 5
  • Changes 2

Closes #1446 (closed)

Looking at the above issue, I can see two problems:

  1. The Vue template is only looking for an album cover
  2. Channels such as podcasts with no series will have their cover art in one of two places: attached to the track or attached to the artist

The first of these is easily resolved. We can add v-else-if directives to grab other covers when no album art is available. This works for track covers, which are returned by the track serializer with no issues. However, the listenings endpoint returns no artist covers. I've tracked this down to the serialize_artist_simple serializer, which contains the following:

def serialize_artist_simple(artist):
    data = {
        "id": artist.id,
        "fid": artist.fid,
        "mbid": str(artist.mbid),
        "name": artist.name,
        "creation_date": DATETIME_FIELD.to_representation(artist.creation_date),
        "modification_date": DATETIME_FIELD.to_representation(artist.modification_date),
        "is_local": artist.is_local,
        "content_category": artist.content_category,
    }
    if "description" in artist._state.fields_cache:
        data["description"] = (
            common_serializers.ContentSerializer(artist.description).data
            if artist.description
            else None
        )

    if "attachment_cover" in artist._state.fields_cache:
        data["cover"] = (
            cover_field.to_representation(artist.attachment_cover)
            if artist.attachment_cover
            else None
        )
    if "channel" in artist._state.fields_cache and artist.get_channel():
        data["channel"] = str(artist.channel.uuid)

    if getattr(artist, "_tracks_count", None) is not None:
        data["tracks_count"] = artist._tracks_count

    if getattr(artist, "_prefetched_tagged_items", None) is not None:
        data["tags"] = [ti.tag.name for ti in artist._prefetched_tagged_items]

    return data

From my testing, none of the attributes that are checking the _state.fields_cache are returning any information. If we remove this check, the information is coming back as expected.

This check is only used in two places, but I don't really understand when, where, or how this fields_cache is set. Looking through Django's docs has not been particularly helpful.

Edited May 09, 2021 by Ciarán Ainsworth
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: 1446-fix-recently-listened