2.0.0 Alpha: Data Refinery
This commit is contained in:
@@ -53,17 +53,39 @@ class WebService:
|
||||
sql = "UPDATE team_lineups SET name=?, description=?, player_ids_json=? WHERE id=?"
|
||||
return execute_db('web', sql, [name, description, ids_json, lineup_id])
|
||||
else:
|
||||
sql = "INSERT INTO team_lineups (name, description, player_ids_json) VALUES (?, ?, ?)"
|
||||
return execute_db('web', sql, [name, description, ids_json])
|
||||
active = 0 if WebService.get_active_lineup() else 1
|
||||
sql = """
|
||||
INSERT INTO team_lineups
|
||||
(name, description, player_ids_json, is_active)
|
||||
VALUES (?, ?, ?, ?)
|
||||
"""
|
||||
return execute_db('web', sql, [name, description, ids_json, active])
|
||||
|
||||
@staticmethod
|
||||
def get_lineups():
|
||||
return query_db('web', "SELECT * FROM team_lineups ORDER BY created_at DESC")
|
||||
return query_db(
|
||||
'web',
|
||||
"SELECT * FROM team_lineups ORDER BY is_active DESC, created_at DESC, id DESC",
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_lineup(lineup_id):
|
||||
return query_db('web', "SELECT * FROM team_lineups WHERE id = ?", [lineup_id], one=True)
|
||||
|
||||
@staticmethod
|
||||
def get_active_lineup():
|
||||
lineup = query_db(
|
||||
'web',
|
||||
"SELECT * FROM team_lineups WHERE is_active = 1 ORDER BY id LIMIT 1",
|
||||
one=True,
|
||||
)
|
||||
if lineup:
|
||||
return lineup
|
||||
return query_db(
|
||||
'web',
|
||||
"SELECT * FROM team_lineups ORDER BY created_at DESC, id DESC LIMIT 1",
|
||||
one=True,
|
||||
)
|
||||
|
||||
# --- Users / Auth ---
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user