mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Charts now show rank change to last range by default (except weeks)
This commit is contained in:
parent
0624996c73
commit
7842b247ad
@ -481,29 +481,38 @@ def module_filterselection(keys,time=True,delimit=False):
|
||||
thismonth = today[:2]
|
||||
thisyear = thismonth[:1]
|
||||
|
||||
### temp!!! this will not allow weekly rank changes
|
||||
weekday = ((now.isoweekday()) % 7)
|
||||
weekbegin = now - datetime.timedelta(days=weekday)
|
||||
weekend = weekbegin + datetime.timedelta(days=6)
|
||||
weekbegin = [weekbegin.year,weekbegin.month,weekbegin.day]
|
||||
weekend = [weekend.year,weekend.month,weekend.day]
|
||||
weekbeginstr = "/".join((str(num) for num in weekbegin))
|
||||
weekendstr = "/".join((str(num) for num in weekend))
|
||||
|
||||
html += "<div>"
|
||||
if timekeys.get("since") == today or timekeys.get("within") == today:
|
||||
html += "<span class='stat_selector' style='opacity:0.5;'>Today</span>"
|
||||
else:
|
||||
html += "<a href='?" + compose_querystring(unchangedkeys,{"since":"today"}) + "'><span class='stat_selector'>Today</span></a>"
|
||||
html += "<a href='?" + compose_querystring(unchangedkeys,{"in":"today"}) + "'><span class='stat_selector'>Today</span></a>"
|
||||
html += " | "
|
||||
|
||||
if keys.get("since") == "sunday":
|
||||
if timekeys.get("since") == weekbegin and timekeys.get("to") == weekend:
|
||||
html += "<span class='stat_selector' style='opacity:0.5;'>This Week</span>"
|
||||
else:
|
||||
html += "<a href='?" + compose_querystring(unchangedkeys,{"since":"sunday"}) + "'><span class='stat_selector'>This Week</span></a>"
|
||||
html += "<a href='?" + compose_querystring(unchangedkeys,{"since":weekbeginstr,"to":weekendstr}) + "'><span class='stat_selector'>This Week</span></a>"
|
||||
html += " | "
|
||||
|
||||
if timekeys.get("since") == thismonth or timekeys.get("within") == thismonth:
|
||||
html += "<span class='stat_selector' style='opacity:0.5;'>This Month</span>"
|
||||
else:
|
||||
html += "<a href='?" + compose_querystring(unchangedkeys,{"since":"month"}) + "'><span class='stat_selector'>This Month</span></a>"
|
||||
html += "<a href='?" + compose_querystring(unchangedkeys,{"in":"month"}) + "'><span class='stat_selector'>This Month</span></a>"
|
||||
html += " | "
|
||||
|
||||
if timekeys.get("since") == thisyear or timekeys.get("within") == thisyear:
|
||||
html += "<span class='stat_selector' style='opacity:0.5;'>This Year</span>"
|
||||
else:
|
||||
html += "<a href='?" + compose_querystring(unchangedkeys,{"since":"year"}) + "'><span class='stat_selector'>This Year</span></a>"
|
||||
html += "<a href='?" + compose_querystring(unchangedkeys,{"in":"year"}) + "'><span class='stat_selector'>This Year</span></a>"
|
||||
html += " | "
|
||||
|
||||
if timekeys.get("since") is None and timekeys.get("within") is None:
|
||||
|
@ -65,14 +65,32 @@ def time_fix(t):
|
||||
|
||||
if isinstance(t,str): t = t.split("/")
|
||||
#if isinstance(t,tuple): t = list(t)
|
||||
try:
|
||||
t = [int(p) for p in t]
|
||||
return t[:3]
|
||||
except:
|
||||
pass
|
||||
|
||||
t = [int(p) for p in t]
|
||||
if t[1].startswith("W"):
|
||||
try:
|
||||
weeknum = int(t[1][1:])
|
||||
return [t[0],"W",t[1]]
|
||||
except:
|
||||
pass
|
||||
|
||||
return t[:3]
|
||||
# checks if time is a week
|
||||
def is_week(t):
|
||||
return ((len(t) == 3) and (t[1] == "W"))
|
||||
def week_to_days(t):
|
||||
pass
|
||||
|
||||
# makes times the same precision level
|
||||
def time_pad(f,t,full=False):
|
||||
f,t = time_fix(f), time_fix(t)
|
||||
|
||||
# week handling
|
||||
|
||||
|
||||
while (len(f) < len(t)) or (full and len(f) < 3):
|
||||
if len(f) == 1: f.append(1)
|
||||
elif len(f) == 2: f.append(1)
|
||||
|
Loading…
Reference in New Issue
Block a user