Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
split solution in Uncategorized category for Web Log Sessions by veky
def checkio(log_text):
from datetime import datetime, timedelta
que, result = {}, []
def commit():
first, last, reqs = que[key]
duration = round((last - first).total_seconds() + 1)
result.append(key + (duration, reqs))
for row in sorted(log_text.split("\n")):
time, user, url = row.lower().split(";;")
when = datetime(*map(int, time.split("-")))
key = user, ".".join(url.split("/")[2].split(".")[-2:])
val = que.setdefault(key, [when, when, 0])
if when - val[1] > timedelta(minutes=30): commit(); val[::2] = when, 0
val[1:] = when, val[2] + 1
for key in que: commit()
return "\n".join(";;".join(map(str, it)) for it in sorted(result))
Dec. 19, 2013
Comments: