Remove more legacy shit

This commit is contained in:
2026-01-25 12:19:27 +01:00
parent 322aa8ab81
commit e7f14278be
9 changed files with 3 additions and 210 deletions

View File

@@ -7,6 +7,8 @@ frontend/
# Data directory (runtime data, not needed for build)
data/
.cache
# Build artifacts
*.exe
*.log

View File

@@ -15,6 +15,7 @@ WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY sqlite-latest.sqlite ./
COPY . .
RUN apt-get update && apt-get install -y \

View File

@@ -1,86 +0,0 @@
package main
import (
"embed"
"strings"
"text/template"
)
//go:embed templates/*.sql.tmpl
var templateFS embed.FS
var (
MainQueryTmpl *template.Template
ShipBreakdownTmpl *template.Template
SystemBreakdownTmpl *template.Template
ModuleStatsTmpl *template.Template
ComprehensiveStatsTmpl *template.Template
)
func init() {
var err error
// Parse templates once at startup
MainQueryTmpl, err = template.ParseFS(templateFS, "templates/main_query.sql.tmpl")
if err != nil {
panic("failed to parse main_query template: " + err.Error())
}
ShipBreakdownTmpl, err = template.ParseFS(templateFS, "templates/ship_breakdown.sql.tmpl")
if err != nil {
panic("failed to parse ship_breakdown template: " + err.Error())
}
SystemBreakdownTmpl, err = template.ParseFS(templateFS, "templates/system_breakdown.sql.tmpl")
if err != nil {
panic("failed to parse system_breakdown template: " + err.Error())
}
ModuleStatsTmpl, err = template.ParseFS(templateFS, "templates/module_stats.sql.tmpl")
if err != nil {
panic("failed to parse module_stats template: " + err.Error())
}
ComprehensiveStatsTmpl, err = template.ParseFS(templateFS, "templates/comprehensive_stats.sql.tmpl")
if err != nil {
panic("failed to parse comprehensive_stats template: " + err.Error())
}
}
// ExecuteTemplate executes a pre-parsed template and builds args
func ExecuteTemplate(tmpl *template.Template, data interface{}) (string, []interface{}, error) {
var queryBuf strings.Builder
if err := tmpl.Execute(&queryBuf, data); err != nil {
return "", nil, err
}
query := strings.TrimSpace(queryBuf.String())
args := []interface{}{}
if qp, ok := data.(QueryParams); ok {
if qp.Ship > 0 {
args = append(args, qp.Ship)
}
if len(qp.Systems) > 0 {
args = append(args, qp.Systems)
}
if len(qp.Modules) > 0 {
args = append(args, qp.Modules)
}
} else if msData, ok := data.(ModuleStatsData); ok {
args = append(args, msData.KillmailIDs)
} else if csData, ok := data.(ComprehensiveStatsData); ok {
if csData.Ship > 0 {
args = append(args, csData.Ship)
}
if len(csData.Systems) > 0 {
args = append(args, csData.Systems)
}
if len(csData.Modules) > 0 {
args = append(args, csData.Modules)
}
args = append(args, csData.KillmailLimit)
}
return query, args, nil
}

View File

@@ -1,53 +0,0 @@
WITH filtered_killmails AS (
SELECT
fk.killmail_id,
fk.solar_system_id,
fk.victim_ship_type_id
FROM killmails fk
{{if .HasModules}}
INNER JOIN modules fm ON fk.killmail_id = fm.killmail_id
{{end}}
WHERE 1=1
{{if .Ship}}AND fk.victim_ship_type_id = ?{{end}}
{{if .Systems}}AND fk.solar_system_id IN ?{{end}}
{{if .HasModules}}AND fm.item_type_id IN ?{{end}}
),
ship_stats AS (
SELECT
victim_ship_type_id as id,
COUNT(*) as count
FROM filtered_killmails
GROUP BY victim_ship_type_id
),
system_stats AS (
SELECT
solar_system_id as id,
COUNT(*) as count
FROM filtered_killmails
GROUP BY solar_system_id
),
module_stats AS (
SELECT
fm.item_type_id,
fm.slot,
COUNT(DISTINCT fm.killmail_id) as count
FROM modules fm
WHERE fm.killmail_id IN (SELECT killmail_id FROM filtered_killmails)
GROUP BY fm.item_type_id, fm.slot
),
limited_killmails AS (
SELECT killmail_id
FROM filtered_killmails
ORDER BY killmail_id
LIMIT ?
)
SELECT
toString(COUNT(*)) as total_killmails,
(SELECT arraySort(x -> x.1, arrayZip(groupArray(id), groupArray(count))) FROM ship_stats) as ships,
(SELECT arraySort(x -> x.1, arrayZip(groupArray(id), groupArray(count))) FROM system_stats) as systems,
(SELECT arraySort(x -> x.1, arrayZip(groupArray(item_type_id), groupArray(count))) FROM module_stats WHERE slot = 'High') as modules_high,
(SELECT arraySort(x -> x.1, arrayZip(groupArray(item_type_id), groupArray(count))) FROM module_stats WHERE slot = 'Mid') as modules_mid,
(SELECT arraySort(x -> x.1, arrayZip(groupArray(item_type_id), groupArray(count))) FROM module_stats WHERE slot = 'Low') as modules_low,
(SELECT arraySort(x -> x.1, arrayZip(groupArray(item_type_id), groupArray(count))) FROM module_stats WHERE slot = 'Rig') as modules_rigs,
(SELECT arraySort(x -> x.1, arrayZip(groupArray(item_type_id), groupArray(count))) FROM module_stats WHERE slot = 'Drone') as modules_drones,
(SELECT groupArray(killmail_id) FROM limited_killmails) as killmail_ids

View File

@@ -1,12 +0,0 @@
SELECT
fk.killmail_id,
fk.solar_system_id,
fk.victim_ship_type_id
FROM killmails fk
{{if .HasModules}}
INNER JOIN modules fm ON fk.killmail_id = fm.killmail_id
{{end}}
WHERE 1=1
{{if .Ship}}AND fk.victim_ship_type_id = ?{{end}}
{{if .Systems}}AND fk.solar_system_id IN ?{{end}}
{{if .HasModules}}AND fm.item_type_id IN ?{{end}}

View File

@@ -1,8 +0,0 @@
SELECT
fm.item_type_id,
fm.slot,
COUNT(DISTINCT fm.killmail_id) as count
FROM modules fm
WHERE fm.killmail_id IN ?
GROUP BY fm.item_type_id, fm.slot
ORDER BY count DESC

View File

@@ -1,12 +0,0 @@
SELECT
fk.victim_ship_type_id,
COUNT(*) as count
FROM killmails fk
{{if .HasModules}}
INNER JOIN modules fm ON fk.killmail_id = fm.killmail_id
{{end}}
WHERE 1=1
{{if .Ship}}AND fk.victim_ship_type_id = ?{{end}}
{{if .Systems}}AND fk.solar_system_id IN ?{{end}}
{{if .HasModules}}AND fm.item_type_id IN ?{{end}}
GROUP BY fk.victim_ship_type_id ORDER BY count DESC

View File

@@ -1,12 +0,0 @@
SELECT
fk.solar_system_id,
COUNT(*) as count
FROM killmails fk
{{if .HasModules}}
INNER JOIN modules fm ON fk.killmail_id = fm.killmail_id
{{end}}
WHERE 1=1
{{if .Ship}}AND fk.victim_ship_type_id = ?{{end}}
{{if .Systems}}AND fk.solar_system_id IN ?{{end}}
{{if .HasModules}}AND fm.item_type_id IN ?{{end}}
GROUP BY fk.solar_system_id ORDER BY count DESC

View File

@@ -1,27 +0,0 @@
package main
func GetModuleSlotByKillmailFlag(flag int64) ModuleSlot {
// Pulled these right out of the fucking database
// | Flag ID | Slot Type | Position | Meaning |
// |---------|-----------------|----------|------------------------------|
// | 11-18 | Low Slots | 1-8 | Low power modules |
// | 19-26 | Mid Slots | 1-8 | Medium power modules |
// | 27-34 | High Slots | 1-8 | High power modules |
// | 92-99 | Rig Slots | 1-8 | Rig modules |
// | 125-132 | SubSystem Slots | 1-8 | Subsystem modules (T3 ships) |
switch {
case flag >= 11 && flag <= 18:
return ModuleSlotLow
case flag >= 19 && flag <= 26:
return ModuleSlotMid
case flag >= 27 && flag <= 34:
return ModuleSlotHigh
case flag >= 92 && flag <= 99:
return ModuleSlotRig
case flag >= 125 && flag <= 132:
return ModuleSlotSubsystem
case flag == 87:
return ModuleSlotDrone
}
return ModuleSlotOther
}