mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 04:59:17 +02:00
Blacked the code
This commit is contained in:
parent
b6fc0051fa
commit
62ca3bd736
279 changed files with 8861 additions and 9527 deletions
|
@ -6,70 +6,47 @@ from funkwhale_api.common import preferences
|
|||
from . import stats
|
||||
|
||||
|
||||
store = memoize.djangocache.Cache('default')
|
||||
memo = memoize.Memoizer(store, namespace='instance:stats')
|
||||
store = memoize.djangocache.Cache("default")
|
||||
memo = memoize.Memoizer(store, namespace="instance:stats")
|
||||
|
||||
|
||||
def get():
|
||||
share_stats = preferences.get('instance__nodeinfo_stats_enabled')
|
||||
private = preferences.get('instance__nodeinfo_private')
|
||||
share_stats = preferences.get("instance__nodeinfo_stats_enabled")
|
||||
private = preferences.get("instance__nodeinfo_private")
|
||||
data = {
|
||||
'version': '2.0',
|
||||
'software': {
|
||||
'name': 'funkwhale',
|
||||
'version': funkwhale_api.__version__
|
||||
},
|
||||
'protocols': ['activitypub'],
|
||||
'services': {
|
||||
'inbound': [],
|
||||
'outbound': []
|
||||
},
|
||||
'openRegistrations': preferences.get('users__registration_enabled'),
|
||||
'usage': {
|
||||
'users': {
|
||||
'total': 0,
|
||||
}
|
||||
},
|
||||
'metadata': {
|
||||
'private': preferences.get('instance__nodeinfo_private'),
|
||||
'shortDescription': preferences.get('instance__short_description'),
|
||||
'longDescription': preferences.get('instance__long_description'),
|
||||
'nodeName': preferences.get('instance__name'),
|
||||
'library': {
|
||||
'federationEnabled': preferences.get('federation__enabled'),
|
||||
'federationNeedsApproval': preferences.get('federation__music_needs_approval'),
|
||||
'anonymousCanListen': preferences.get('common__api_authentication_required'),
|
||||
"version": "2.0",
|
||||
"software": {"name": "funkwhale", "version": funkwhale_api.__version__},
|
||||
"protocols": ["activitypub"],
|
||||
"services": {"inbound": [], "outbound": []},
|
||||
"openRegistrations": preferences.get("users__registration_enabled"),
|
||||
"usage": {"users": {"total": 0}},
|
||||
"metadata": {
|
||||
"private": preferences.get("instance__nodeinfo_private"),
|
||||
"shortDescription": preferences.get("instance__short_description"),
|
||||
"longDescription": preferences.get("instance__long_description"),
|
||||
"nodeName": preferences.get("instance__name"),
|
||||
"library": {
|
||||
"federationEnabled": preferences.get("federation__enabled"),
|
||||
"federationNeedsApproval": preferences.get(
|
||||
"federation__music_needs_approval"
|
||||
),
|
||||
"anonymousCanListen": preferences.get(
|
||||
"common__api_authentication_required"
|
||||
),
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
if share_stats:
|
||||
getter = memo(
|
||||
lambda: stats.get(),
|
||||
max_age=600
|
||||
)
|
||||
getter = memo(lambda: stats.get(), max_age=600)
|
||||
statistics = getter()
|
||||
data['usage']['users']['total'] = statistics['users']
|
||||
data['metadata']['library']['tracks'] = {
|
||||
'total': statistics['tracks'],
|
||||
}
|
||||
data['metadata']['library']['artists'] = {
|
||||
'total': statistics['artists'],
|
||||
}
|
||||
data['metadata']['library']['albums'] = {
|
||||
'total': statistics['albums'],
|
||||
}
|
||||
data['metadata']['library']['music'] = {
|
||||
'hours': statistics['music_duration']
|
||||
}
|
||||
data["usage"]["users"]["total"] = statistics["users"]
|
||||
data["metadata"]["library"]["tracks"] = {"total": statistics["tracks"]}
|
||||
data["metadata"]["library"]["artists"] = {"total": statistics["artists"]}
|
||||
data["metadata"]["library"]["albums"] = {"total": statistics["albums"]}
|
||||
data["metadata"]["library"]["music"] = {"hours": statistics["music_duration"]}
|
||||
|
||||
data['metadata']['usage'] = {
|
||||
'favorites': {
|
||||
'tracks': {
|
||||
'total': statistics['track_favorites'],
|
||||
}
|
||||
},
|
||||
'listenings': {
|
||||
'total': statistics['listenings']
|
||||
}
|
||||
data["metadata"]["usage"] = {
|
||||
"favorites": {"tracks": {"total": statistics["track_favorites"]}},
|
||||
"listenings": {"total": statistics["listenings"]},
|
||||
}
|
||||
return data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue