kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Merge branch 'nodeinfo-care' into 'develop'
Include only local content in nodeinfo stats, added downloads count See merge request funkwhale/funkwhale!1028merge-requests/1042/head
commit
11a42e362d
|
@ -87,6 +87,7 @@ def get():
|
|||
data["metadata"]["usage"] = {
|
||||
"favorites": {"tracks": {"total": statistics["track_favorites"]}},
|
||||
"listenings": {"total": statistics["listenings"]},
|
||||
"downloads": {"total": statistics["downloads"]},
|
||||
}
|
||||
if not auth_required:
|
||||
data["metadata"]["knownNodesListUrl"] = federation_utils.full_url(
|
||||
|
|
|
@ -17,6 +17,7 @@ def get():
|
|||
"artists": get_artists(),
|
||||
"track_favorites": get_track_favorites(),
|
||||
"listenings": get_listenings(),
|
||||
"downloads": get_downloads(),
|
||||
"music_duration": get_music_duration(),
|
||||
}
|
||||
|
||||
|
@ -43,15 +44,19 @@ def get_track_favorites():
|
|||
|
||||
|
||||
def get_tracks():
|
||||
return models.Track.objects.count()
|
||||
return models.Track.objects.local().count()
|
||||
|
||||
|
||||
def get_albums():
|
||||
return models.Album.objects.count()
|
||||
return models.Album.objects.local().count()
|
||||
|
||||
|
||||
def get_artists():
|
||||
return models.Artist.objects.count()
|
||||
return models.Artist.objects.local().count()
|
||||
|
||||
|
||||
def get_downloads():
|
||||
return models.Track.objects.aggregate(d=Sum("downloads_count"))["d"] or 0
|
||||
|
||||
|
||||
def get_music_duration():
|
||||
|
|
|
@ -27,6 +27,7 @@ def test_nodeinfo_dump(preferences, mocker, avatar):
|
|||
"track_favorites": 5,
|
||||
"music_duration": 6,
|
||||
"listenings": 7,
|
||||
"downloads": 42,
|
||||
}
|
||||
mocker.patch("funkwhale_api.instance.stats.get", return_value=stats)
|
||||
|
||||
|
@ -61,6 +62,7 @@ def test_nodeinfo_dump(preferences, mocker, avatar):
|
|||
"usage": {
|
||||
"favorites": {"tracks": {"total": stats["track_favorites"]}},
|
||||
"listenings": {"total": stats["listenings"]},
|
||||
"downloads": {"total": stats["downloads"]},
|
||||
},
|
||||
"supportedUploadExtensions": music_utils.SUPPORTED_EXTENSIONS,
|
||||
"allowList": {"enabled": False, "domains": None},
|
||||
|
|
|
@ -34,17 +34,17 @@ def test_get_track_favorites(mocker):
|
|||
|
||||
|
||||
def test_get_tracks(mocker):
|
||||
mocker.patch("funkwhale_api.music.models.Track.objects.count", return_value=42)
|
||||
mocker.patch("funkwhale_api.music.models.TrackQuerySet.count", return_value=42)
|
||||
assert stats.get_tracks() == 42
|
||||
|
||||
|
||||
def test_get_albums(mocker):
|
||||
mocker.patch("funkwhale_api.music.models.Album.objects.count", return_value=42)
|
||||
mocker.patch("funkwhale_api.music.models.AlbumQuerySet.count", return_value=42)
|
||||
assert stats.get_albums() == 42
|
||||
|
||||
|
||||
def test_get_artists(mocker):
|
||||
mocker.patch("funkwhale_api.music.models.Artist.objects.count", return_value=42)
|
||||
mocker.patch("funkwhale_api.music.models.ArtistQuerySet.count", return_value=42)
|
||||
assert stats.get_artists() == 42
|
||||
|
||||
|
||||
|
@ -57,6 +57,7 @@ def test_get(mocker):
|
|||
"track_favorites",
|
||||
"listenings",
|
||||
"music_duration",
|
||||
"downloads",
|
||||
]
|
||||
[
|
||||
mocker.patch.object(stats, "get_{}".format(k), return_value=i)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Include only local content in nodeinfo stats, added downloads count
|
Ładowanie…
Reference in New Issue