switched to fully self contained docker

This commit is contained in:
David Schroeder
2026-07-26 14:01:20 -05:00
parent 0ed0fb5817
commit 5d2f90ce24
34 changed files with 688 additions and 672 deletions
+29 -26
View File
@@ -215,10 +215,10 @@ func auditQuery(filters auditFilters, limit int) (string, []any) {
var arguments []any
timeClauses := map[string]string{
"24h": " AND ae.created_at >= UTC_TIMESTAMP(6) - INTERVAL 1 DAY",
"7d": " AND ae.created_at >= UTC_TIMESTAMP(6) - INTERVAL 7 DAY",
"30d": " AND ae.created_at >= UTC_TIMESTAMP(6) - INTERVAL 30 DAY",
"90d": " AND ae.created_at >= UTC_TIMESTAMP(6) - INTERVAL 90 DAY",
"24h": " AND ae.created_at >= datetime('now', '-1 day')",
"7d": " AND ae.created_at >= datetime('now', '-7 days')",
"30d": " AND ae.created_at >= datetime('now', '-30 days')",
"90d": " AND ae.created_at >= datetime('now', '-90 days')",
}
query += timeClauses[filters.TimeRange]
@@ -240,11 +240,11 @@ func auditQuery(filters auditFilters, limit int) (string, []any) {
if filter.value == "" {
continue
}
query += " AND LOCATE(?, " + filter.column + ") > 0"
query += " AND instr(" + filter.column + ", ?) > 0"
arguments = append(arguments, filter.value)
}
if filters.SourceIP != "" {
query += " AND LOCATE(?, ae.source_ip) > 0"
query += " AND instr(ae.source_ip, ?) > 0"
arguments = append(arguments, filters.SourceIP)
}
query += " ORDER BY ae.created_at DESC LIMIT ?"
@@ -325,21 +325,23 @@ func (s *Server) listAuthorizations(r *http.Request) ([]authorizationRecord, err
WHERE h.authorization_id = a.id),
a.created_at, a.expires_at, a.revoked_at,
COALESCE((
SELECT GROUP_CONCAT(p.display_name
ORDER BY p.display_name SEPARATOR ', ')
FROM authorization_packages ap
JOIN packages p ON p.id = ap.package_id
WHERE ap.authorization_id = a.id
SELECT GROUP_CONCAT(display_name, ', ')
FROM (SELECT p.display_name
FROM authorization_packages ap
JOIN packages p ON p.id = ap.package_id
WHERE ap.authorization_id = a.id
ORDER BY p.display_name)
), ''),
COALESCE((
SELECT GROUP_CONCAT(ia.display_name
ORDER BY ia.sort_order, ia.display_name SEPARATOR ', ')
FROM authorization_actions aa
JOIN installer_actions ia ON ia.slug = aa.action_slug
WHERE aa.authorization_id = a.id
SELECT GROUP_CONCAT(display_name, ', ')
FROM (SELECT ia.display_name
FROM authorization_actions aa
JOIN installer_actions ia ON ia.slug = aa.action_slug
WHERE aa.authorization_id = a.id
ORDER BY ia.sort_order, ia.display_name)
), '')
FROM authorizations a
WHERE a.created_at > UTC_TIMESTAMP(6) - INTERVAL 30 DAY
WHERE a.created_at > datetime('now', '-30 days')
ORDER BY a.created_at DESC
LIMIT 100`,
)
@@ -489,7 +491,7 @@ func (s *Server) handleRevokeAuthorization(w http.ResponseWriter, r *http.Reques
result, err := s.db.ExecContext(
r.Context(),
`UPDATE authorizations
SET revoked_at = COALESCE(revoked_at, UTC_TIMESTAMP(6))
SET revoked_at = COALESCE(revoked_at, CURRENT_TIMESTAMP)
WHERE id = ?`,
id,
)
@@ -504,7 +506,7 @@ func (s *Server) handleRevokeAuthorization(w http.ResponseWriter, r *http.Reques
}
_, _ = s.db.ExecContext(
r.Context(),
`UPDATE download_sessions SET revoked_at = UTC_TIMESTAMP(6)
`UPDATE download_sessions SET revoked_at = CURRENT_TIMESTAMP
WHERE authorization_id = ? AND revoked_at IS NULL`,
id,
)
@@ -568,13 +570,14 @@ func (s *Server) savePackage(
`INSERT INTO packages
(slug, display_name, package_name, package_version, file_name, sha256, enabled)
VALUES (?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE
display_name = VALUES(display_name),
package_name = VALUES(package_name),
package_version = VALUES(package_version),
file_name = VALUES(file_name),
sha256 = VALUES(sha256),
enabled = VALUES(enabled)`,
ON CONFLICT(slug) DO UPDATE SET
display_name = excluded.display_name,
package_name = excluded.package_name,
package_version = excluded.package_version,
file_name = excluded.file_name,
sha256 = excluded.sha256,
enabled = excluded.enabled,
updated_at = CURRENT_TIMESTAMP`,
slug,
displayName,
packageName,