style: Apply code formatting with go fmt
- Run 'make format' to ensure all Go code follows standard formatting - Maintains consistent code style across the entire codebase - No functional changes, only whitespace and formatting improvements
This commit is contained in:
parent
4fd0846127
commit
2bffa2c418
19 changed files with 543 additions and 527 deletions
|
|
@ -55,13 +55,13 @@ type OriginConfig struct {
|
|||
// - Concurrent broadcast system for WebSocket clients
|
||||
// - CORS support for cross-origin web applications
|
||||
type Server struct {
|
||||
host string // Bind address for HTTP server
|
||||
port int // TCP port for HTTP server
|
||||
merger *merger.Merger // Data source for aircraft information
|
||||
host string // Bind address for HTTP server
|
||||
port int // TCP port for HTTP server
|
||||
merger *merger.Merger // Data source for aircraft information
|
||||
database *database.Database // Optional database for persistence
|
||||
staticFiles embed.FS // Embedded static web assets
|
||||
server *http.Server // HTTP server instance
|
||||
origin OriginConfig // Geographic reference point
|
||||
staticFiles embed.FS // Embedded static web assets
|
||||
server *http.Server // HTTP server instance
|
||||
origin OriginConfig // Geographic reference point
|
||||
|
||||
// WebSocket management
|
||||
wsClients map[*websocket.Conn]bool // Active WebSocket client connections
|
||||
|
|
@ -919,19 +919,19 @@ func (s *Server) handleGetDatabaseStatus(w http.ResponseWriter, r *http.Request)
|
|||
}
|
||||
|
||||
response := make(map[string]interface{})
|
||||
|
||||
|
||||
// Get database path and size information
|
||||
dbConfig := s.database.GetConfig()
|
||||
dbPath := dbConfig.Path
|
||||
response["path"] = dbPath
|
||||
|
||||
|
||||
// Get file size and modification time
|
||||
if stat, err := os.Stat(dbPath); err == nil {
|
||||
response["size_bytes"] = stat.Size()
|
||||
response["size_mb"] = float64(stat.Size()) / (1024 * 1024)
|
||||
response["modified"] = stat.ModTime().Unix()
|
||||
}
|
||||
|
||||
|
||||
// Get optimization statistics
|
||||
optimizer := database.NewOptimizationManager(s.database, dbConfig)
|
||||
if optimizationStats, err := optimizer.GetOptimizationStats(); err == nil {
|
||||
|
|
@ -945,14 +945,14 @@ func (s *Server) handleGetDatabaseStatus(w http.ResponseWriter, r *http.Request)
|
|||
response["last_vacuum"] = optimizationStats.LastVacuum.Unix()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get history statistics
|
||||
historyStats, err := s.database.GetHistoryManager().GetStatistics()
|
||||
if err != nil {
|
||||
log.Printf("Error getting history statistics: %v", err)
|
||||
historyStats = make(map[string]interface{})
|
||||
}
|
||||
|
||||
|
||||
// Get callsign statistics if available
|
||||
callsignStats := make(map[string]interface{})
|
||||
if callsignManager := s.database.GetCallsignManager(); callsignManager != nil {
|
||||
|
|
@ -963,23 +963,23 @@ func (s *Server) handleGetDatabaseStatus(w http.ResponseWriter, r *http.Request)
|
|||
callsignStats = stats
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get record counts for reference data
|
||||
var airportCount, airlineCount int
|
||||
s.database.GetConnection().QueryRow(`SELECT COUNT(*) FROM airports`).Scan(&airportCount)
|
||||
s.database.GetConnection().QueryRow(`SELECT COUNT(*) FROM airlines`).Scan(&airlineCount)
|
||||
|
||||
|
||||
referenceData := make(map[string]interface{})
|
||||
referenceData["airports"] = airportCount
|
||||
referenceData["airlines"] = airlineCount
|
||||
|
||||
|
||||
response["database_available"] = true
|
||||
response["path"] = dbPath
|
||||
response["reference_data"] = referenceData
|
||||
response["history"] = historyStats
|
||||
response["callsign"] = callsignStats
|
||||
response["timestamp"] = time.Now().Unix()
|
||||
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
|
@ -993,20 +993,20 @@ func (s *Server) handleGetDataSources(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// Create data loader instance
|
||||
loader := database.NewDataLoader(s.database.GetConnection())
|
||||
|
||||
|
||||
availableSources := database.GetAvailableDataSources()
|
||||
loadedSources, err := loader.GetLoadedDataSources()
|
||||
if err != nil {
|
||||
log.Printf("Error getting loaded data sources: %v", err)
|
||||
loadedSources = []database.DataSource{}
|
||||
}
|
||||
|
||||
|
||||
response := map[string]interface{}{
|
||||
"available": availableSources,
|
||||
"loaded": loadedSources,
|
||||
"timestamp": time.Now().Unix(),
|
||||
}
|
||||
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
|
@ -1021,7 +1021,7 @@ func (s *Server) handleGetCallsignInfo(w http.ResponseWriter, r *http.Request) {
|
|||
// Extract callsign from URL parameters
|
||||
vars := mux.Vars(r)
|
||||
callsign := vars["callsign"]
|
||||
|
||||
|
||||
if callsign == "" {
|
||||
http.Error(w, "Callsign parameter required", http.StatusBadRequest)
|
||||
return
|
||||
|
|
@ -1036,7 +1036,7 @@ func (s *Server) handleGetCallsignInfo(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
response := map[string]interface{}{
|
||||
"callsign": callsignInfo,
|
||||
"callsign": callsignInfo,
|
||||
"timestamp": time.Now().Unix(),
|
||||
}
|
||||
|
||||
|
|
@ -1070,12 +1070,12 @@ func (s *Server) debugEmbeddedFiles() {
|
|||
func (s *Server) handleDatabasePage(w http.ResponseWriter, r *http.Request) {
|
||||
// Debug embedded files first
|
||||
s.debugEmbeddedFiles()
|
||||
|
||||
|
||||
// Try to read the database HTML file from embedded assets
|
||||
data, err := s.staticFiles.ReadFile("static/database.html")
|
||||
if err != nil {
|
||||
log.Printf("Error reading database.html: %v", err)
|
||||
|
||||
|
||||
// Fallback: serve a simple HTML page with API calls
|
||||
fallbackHTML := `<!DOCTYPE html>
|
||||
<html><head><title>Database Status - SkyView</title></head>
|
||||
|
|
@ -1091,7 +1091,7 @@ fetch('/api/database/status')
|
|||
});
|
||||
</script>
|
||||
</body></html>`
|
||||
|
||||
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.Write([]byte(fallbackHTML))
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue