mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added optional stat report
This commit is contained in:
parent
68000067bc
commit
091c86a7ce
@ -7,7 +7,7 @@ author = {
|
||||
"email":"maloja@krateng.dev",
|
||||
"github": "krateng"
|
||||
}
|
||||
version = 2,1,2
|
||||
version = 2,1,3
|
||||
versionstr = ".".join(str(n) for n in version)
|
||||
|
||||
|
||||
|
@ -84,6 +84,15 @@ def setup():
|
||||
if name == "": name = "Generic Maloja User"
|
||||
settings.update_settings("settings/settings.ini",{"NAME":name},create_new=True)
|
||||
|
||||
if settings.get_settings("SEND_STATS") is None:
|
||||
print("I would like to know how many people use Maloja. Would it be okay to send a daily ping to my server (this contains no data that isn't accessible via your web interface already)? [Y/n]")
|
||||
answer = input()
|
||||
if answer.lower() in ["y","yes","yea","1","positive","true",""]:
|
||||
settings.update_settings("settings/settings.ini",{"SEND_STATS":True},create_new=True)
|
||||
settings.update_settings("settings/settings.ini",{"PUBLIC_URL":None},create_new=True)
|
||||
else:
|
||||
settings.update_settings("settings/settings.ini",{"SEND_STATS":False},create_new=True)
|
||||
|
||||
|
||||
def getInstance():
|
||||
try:
|
||||
|
@ -982,6 +982,7 @@ def build_db():
|
||||
#start regular tasks
|
||||
utilities.update_medals()
|
||||
utilities.update_weekly()
|
||||
utilities.send_stats()
|
||||
|
||||
global db_rulestate
|
||||
db_rulestate = utilities.consistentRulestate("scrobbles",cla.checksums)
|
||||
|
@ -15,6 +15,7 @@ from doreah.logging import log
|
||||
from doreah.regular import yearly, daily
|
||||
|
||||
from .external import api_request_track, api_request_artist
|
||||
from .__init__ import version
|
||||
|
||||
|
||||
|
||||
@ -484,3 +485,29 @@ def update_weekly():
|
||||
for t in get_charts_tracks(timerange=week):
|
||||
track = (frozenset(t["track"]["artists"]),t["track"]["title"])
|
||||
if t["rank"] == 1: WEEKLY_TOPTRACKS[track] = WEEKLY_TOPTRACKS.setdefault(track,0) + 1
|
||||
|
||||
|
||||
@daily
|
||||
def send_stats():
|
||||
if settings.get_settings("SEND_STATS"):
|
||||
|
||||
log("Sending daily stats report...")
|
||||
|
||||
from .database import ARTISTS, TRACKS, SCROBBLES
|
||||
|
||||
keys = {
|
||||
"url":"https://myrcella.krateng.ch/malojastats",
|
||||
"method":"POST",
|
||||
"headers":{"Content-Type": "application/json"},
|
||||
"data":json.dumps({
|
||||
"name":settings.get_settings("NAME"),
|
||||
"url":settings.get_settings("PUBLIC_URL"),
|
||||
"version":".".join(str(d) for d in version),
|
||||
"artists":len(ARTISTS),
|
||||
"tracks":len(TRACKS),
|
||||
"scrobbles":len(SCROBBLES)
|
||||
}).encode("utf-8")
|
||||
}
|
||||
req = urllib.request.Request(**keys)
|
||||
response = urllib.request.urlopen(req)
|
||||
log("Sent daily report!")
|
||||
|
Loading…
Reference in New Issue
Block a user