Add from attribute to genre tag spec

Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2592>
environments/review-docs-genre-pd4r81/deployments/19389
Ciarán Ainsworth 2024-04-14 15:19:26 +02:00
rodzic e1e0045a23
commit a2579bdc60
1 zmienionych plików z 157 dodań i 10 usunięć

Wyświetl plik

@ -6,7 +6,7 @@ Funkwhale offers users a facility to assign genre tags to items such as tracks,
## The solution
To provide the best experience for new Funkwhale users, we should prepopulate this table with [genre tags from Musicbrainz](https://musicbrainz.org/genres). Doing this enables users to easily search for and select the tags they want to assign to their content without needing to create custom tags or upload tagged content.
To provide the best experience for new Funkwhale users, we should pre-populate this table with [genre tags from Musicbrainz](https://musicbrainz.org/genres). Doing this enables users to easily search for and select the tags they want to assign to their content without needing to create custom tags or upload tagged content.
Having these tags easily available also facilitates better tagging within Funkwhale in future, reducing the reliance on external tools such as Picard.
@ -16,23 +16,163 @@ Having these tags easily available also facilitates better tagging within Funkwh
The `tags_tag` table contains the following fields:
| Field | Data type | Description | Relations | Constraints |
| ---------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | -------------- |
| `id` | Integer | The randomly generated table ID | `tags_taggeditem.tag_id` foreign key | None |
| `musicbrainz_id` | UUID | The Musicbrainz genre tag `id`. Used to identify the tag in Musicbrainz fetches | None | None |
| `name` | String | The name of the tag. Assigned by Funkwhale during creation for use in URLs. Uses Pascal casing for consistency | None | Must be unique |
| `display_name` | String | The name of the tag as the user entered it or as it was originally written by Musicbrainz. Lowercase, normalizes spaces | None | None |
| `creation_date` | Timestamp with time zone | The date on which the tag was created | None | None |
| Field | Data type | Description | Relations | Constraints |
| ---------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | -------------------------------------- |
| `id` | Integer | The randomly generated table ID | `tags_taggeditem.tag_id` foreign key | None |
| `musicbrainz_id` | UUID | The Musicbrainz genre tag `id`. Used to identify the tag in Musicbrainz fetches | None | None |
| `name` | String | The name of the tag. Assigned by Funkwhale during creation for use in URLs. Uses Pascal casing for consistency | None | Must be unique |
| `display_name` | String | The name of the tag as the user entered it or as it was originally written by Musicbrainz. Lowercase, normalizes spaces | None | None |
| `creation_date` | Timestamp with time zone | The date on which the tag was created | None | None |
| `from` | Enum<String> | The origin of the tag. | None | Must be either `None` or `MusicBrainz` |
#### Musicbrainz fetch task
To keep Funkwhale's database up-to-date with Musicbrainz's genre tags, we must fetch information from Musicbrainz periodically. We can use the following endpoint to fetch the information:
```url
```text
https://musicbrainz.org/ws/2/genre/all
```
This endpoint accepts the `application/json` header for a JSON response. See the [Musicbrainz API documentation](https://musicbrainz.org/doc/MusicBrainz_API) for more information.
This endpoint accepts the `application/json` header for a JSON response. See the [Musicbrainz API documentation](https://musicbrainz.org/doc/MusicBrainz_API) for more information. The pagination can be controlled by passing the following options:
- `limit`: the number of results to return
- `offset`: the starting point of the page
The fetch task should fetch **all** pages, using the response `genre-count` to determine how many offset positions to pass.
```json
{
"genre-count": 1913,
"genre-offset": 24,
"genres": [
{
"disambiguation": "",
"id": "243975aa-1250-4429-8bd3-97080af44cf7",
"name": "afro trap"
},
{
"name": "afro-cuban jazz",
"id": "cdb11433-1ff1-4c88-be16-717567e1342f",
"disambiguation": ""
},
{
"name": "afro-funk",
"disambiguation": "",
"id": "fc00175b-2be9-4d73-ba91-27b3ca827223"
},
{
"name": "afro-jazz",
"disambiguation": "",
"id": "6f33d775-b4e2-473c-a7db-e34c525cc52d"
},
{
"disambiguation": "",
"id": "a7e0229c-6e53-45f1-a6f2-a791e78b159e",
"name": "afro-zouk"
},
{
"disambiguation": "funk/soul + West African sounds",
"id": "fcc58a18-9326-4c92-8b29-c294d44379c3",
"name": "afrobeat"
},
{
"id": "b8793fdb-bbc8-4418-a6f8-05eafbbe07ef",
"disambiguation": "West African urban/pop music",
"name": "afrobeats"
},
{
"name": "afropiano",
"id": "d42b567f-0952-424b-959d-bee6e5961cc0",
"disambiguation": ""
},
{
"disambiguation": "",
"id": "52349b68-9cad-496e-8785-00d53f410246",
"name": "afroswing"
},
{
"name": "agbadza",
"disambiguation": "",
"id": "c6d1e78b-ac82-4bb8-89d5-21e3226dc906"
},
{
"disambiguation": "",
"id": "b8ae0a3c-5826-4104-9663-fe8f828effa9",
"name": "agbekor"
},
{
"name": "aggrotech",
"disambiguation": "",
"id": "c844c144-90a8-4288-981e-e38275592688"
},
{
"name": "ahwash",
"id": "4802e6e4-f403-41d1-8e58-76e5cf4df81d",
"disambiguation": ""
},
{
"id": "50cc5641-b4f9-40b7-bf7a-6d903ac6c1c5",
"disambiguation": "",
"name": "aita"
},
{
"id": "aebbce35-0e8b-40e9-b04c-bebbbda124d0",
"disambiguation": "",
"name": "akishibu-kei"
},
{
"name": "al jeel",
"disambiguation": "",
"id": "0f8d3ff4-8cda-42c4-b462-10352cd01606"
},
{
"name": "algerian chaabi",
"id": "998efb76-2f98-41c8-8c5f-74c32e405e9f",
"disambiguation": ""
},
{
"name": "algorave",
"id": "e0a9d0d1-b86f-4344-82a9-022a84627087",
"disambiguation": ""
},
{
"name": "alloukou",
"disambiguation": "",
"id": "e367c884-d94d-4fba-abc4-8ac51d167ccf"
},
{
"disambiguation": "",
"id": "ef1d11cc-e70f-4885-ad6c-103f060d33b2",
"name": "alpenrock"
},
{
"disambiguation": "",
"id": "5f9cba3d-1a9f-46cd-8c49-7ed78d1f3354",
"name": "alternative country"
},
{
"name": "alternative dance",
"id": "8301f73c-9166-4108-bfeb-4fd22dc19083",
"disambiguation": ""
},
{
"name": "alternative folk",
"id": "0b48a36c-630f-4ee7-8cf3-480e3dd8be65",
"disambiguation": ""
},
{
"name": "alternative hip hop",
"disambiguation": "",
"id": "924943cd-73c8-45c0-96eb-74f2a15e5d6e"
},
{
"disambiguation": "",
"id": "7c4d0994-4c49-4c74-8763-df27fc0084cc",
"name": "alté"
}
]
}
```
The fetch task should run _initially upon first startup_ and then _monthly_ thereafter. The pod admin must be able to disable this job or run it manually at their discretion.
@ -73,6 +213,13 @@ Users should be able to search for tags using Funkwhale's in-app search. In sear
The `display_name` of the tag should be shown in pills against cards.
### Admin options
If the admin of a server wants to **disable** MusicBrainz tagging, they should be able to toggle this in their instance settings. If the setting is **disabled**:
- The sync task should stop running
- Any tags with a `from` attribute of `MusicBrainz` should be excluded from API queries.
## Availability
- [x] Admin panel