parent
a1731ce47f
commit
75730c8a7c
27
activity.py
27
activity.py
|
@ -1,5 +1,6 @@
|
||||||
from django_coreprotect.models import SessionResult, ActivityResult
|
from django_coreprotect.models import SessionResult, ActivityResult
|
||||||
from django_coreprotect.utils import safe_int
|
from django_coreprotect.utils import safe_int
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
class ActivityForm:
|
class ActivityForm:
|
||||||
|
@ -26,17 +27,31 @@ def activity_data(request):
|
||||||
|
|
||||||
def activity_results(form):
|
def activity_results(form):
|
||||||
query = ""
|
query = ""
|
||||||
players = []
|
|
||||||
|
players_clause = ""
|
||||||
if form.players:
|
if form.players:
|
||||||
|
players = []
|
||||||
for player in form.players.split(","):
|
for player in form.players.split(","):
|
||||||
players.append(player.strip())
|
players.append(player.strip())
|
||||||
players_clause = " WHERE ({}) ".format(" OR ".join(["player LIKE '%%{}%%'".format(p) for p in players]))
|
players_clause = " WHERE ({}) ".format(" OR ".join(["player LIKE '%%{}%%'".format(p) for p in players]))
|
||||||
|
|
||||||
|
time_clause = ""
|
||||||
|
if form.date_from or form.date_to:
|
||||||
|
df, dt = form.date_from, form.date_to
|
||||||
|
if form.date_from and not form.date_to:
|
||||||
|
dt = datetime.now().timestamp()
|
||||||
|
if form.date_to and not form.date_from:
|
||||||
|
df = datetime.now().timestamp()
|
||||||
|
time_clause = " HAVING unix BETWEEN {} AND {} ".format(df, dt)
|
||||||
|
|
||||||
|
if players_clause or time_clause:
|
||||||
query = '''SELECT
|
query = '''SELECT
|
||||||
0 AS id, cs.time AS unix, cu.user AS player, cs.action
|
0 AS id, cs.time AS unix, cu.user AS player, cs.action
|
||||||
FROM co_session cs
|
FROM co_session cs
|
||||||
JOIN co_user cu ON cs.user = cu.rowid
|
JOIN co_user cu ON cs.user = cu.rowid
|
||||||
{players}
|
{players}
|
||||||
'''.format(players=players_clause)
|
{time}
|
||||||
|
'''.format(players=players_clause, time=time_clause)
|
||||||
|
|
||||||
if query:
|
if query:
|
||||||
print(query)
|
print(query)
|
||||||
|
|
8
gui.py
8
gui.py
|
@ -94,7 +94,7 @@ def gui_data(request):
|
||||||
|
|
||||||
def gui_results(form):
|
def gui_results(form):
|
||||||
queries = []
|
queries = []
|
||||||
ignore_environment = " AND player NOT LIKE '#%%' " if form.ignore_environment else ""
|
ignore_environment = " AND cu.user NOT LIKE '#%%' " if form.ignore_environment else ""
|
||||||
oldest_first = " ASC " if form.oldest_first else " DESC "
|
oldest_first = " ASC " if form.oldest_first else " DESC "
|
||||||
|
|
||||||
coords = []
|
coords = []
|
||||||
|
@ -112,12 +112,12 @@ def gui_results(form):
|
||||||
if form.players:
|
if form.players:
|
||||||
for player in form.players.split(","):
|
for player in form.players.split(","):
|
||||||
players.append(player.strip())
|
players.append(player.strip())
|
||||||
players_clause = " AND ({})".format(" OR ".join(["player LIKE '%%{}%%'".format(p) for p in players]))
|
players_clause = " AND ({})".format(" OR ".join(["cu.user LIKE '%%{}%%'".format(p) for p in players]))
|
||||||
|
|
||||||
worlds_clause = ""
|
worlds_clause = ""
|
||||||
worlds = [world["id"] for world in form.worlds if world["checked"]]
|
worlds = [world["id"] for world in form.worlds if world["checked"]]
|
||||||
if len(worlds):
|
if len(worlds):
|
||||||
worlds_clause = " AND cw.id IN ({})".format(",".join(worlds))
|
worlds_clause = " AND cw.rowid IN ({})".format(",".join(worlds))
|
||||||
|
|
||||||
time_clause = ""
|
time_clause = ""
|
||||||
if form.date_from or form.date_to:
|
if form.date_from or form.date_to:
|
||||||
|
@ -126,7 +126,7 @@ def gui_results(form):
|
||||||
dt = datetime.now().timestamp()
|
dt = datetime.now().timestamp()
|
||||||
if form.date_to and not form.date_from:
|
if form.date_to and not form.date_from:
|
||||||
df = datetime.now().timestamp()
|
df = datetime.now().timestamp()
|
||||||
time_clause = " AND unix BETWEEN {} AND {} ".format(df, dt)
|
time_clause = " HAVING unix BETWEEN {} AND {} ".format(df, dt)
|
||||||
|
|
||||||
# Block Break, Block Place, and Interact
|
# Block Break, Block Place, and Interact
|
||||||
block_actions = []
|
block_actions = []
|
||||||
|
|
Loading…
Reference in New Issue