4 Commits

Author SHA1 Message Date
Fran Jurmanović
4ab94de529 resolve test failing
All checks were successful
Release and Deploy / build (push) Successful in 2m12s
Release and Deploy / deploy (push) Successful in 27s
2025-09-14 22:05:25 +02:00
Fran Jurmanović
b3f89593fb replace id type
Some checks failed
Release and Deploy / build (push) Failing after 2m7s
Release and Deploy / deploy (push) Has been skipped
2025-09-14 17:08:50 +02:00
Fran Jurmanović
2a863c51e9 update state history query
All checks were successful
Release and Deploy / build (push) Successful in 3m18s
Release and Deploy / deploy (push) Successful in 27s
2025-09-13 14:41:52 +02:00
Fran Jurmanović
a70d923a6a revert to powershell executable 2025-08-17 16:53:44 +02:00
4 changed files with 30 additions and 25 deletions

View File

@@ -1,5 +1,7 @@
package model package model
import "github.com/google/uuid"
type SessionCount struct { type SessionCount struct {
Name string `json:"name"` Name string `json:"name"`
Count int `json:"count"` Count int `json:"count"`
@@ -7,30 +9,30 @@ type SessionCount struct {
type DailyActivity struct { type DailyActivity struct {
Date string `json:"date"` Date string `json:"date"`
SessionsCount int `json:"sessionsCount"` SessionsCount int `json:"sessionsCount"`
} }
type PlayerCountPoint struct { type PlayerCountPoint struct {
Timestamp string `json:"timestamp"` Timestamp string `json:"timestamp"`
Count float64 `json:"count"` Count float64 `json:"count"`
} }
type StateHistoryStats struct { type StateHistoryStats struct {
AveragePlayers float64 `json:"averagePlayers"` AveragePlayers float64 `json:"averagePlayers"`
PeakPlayers int `json:"peakPlayers"` PeakPlayers int `json:"peakPlayers"`
TotalSessions int `json:"totalSessions"` TotalSessions int `json:"totalSessions"`
TotalPlaytime int `json:"totalPlaytime" gorm:"-"` // in minutes TotalPlaytime int `json:"totalPlaytime" gorm:"-"` // in minutes
PlayerCountOverTime []PlayerCountPoint `json:"playerCountOverTime" gorm:"-"` PlayerCountOverTime []PlayerCountPoint `json:"playerCountOverTime" gorm:"-"`
SessionTypes []SessionCount `json:"sessionTypes" gorm:"-"` SessionTypes []SessionCount `json:"sessionTypes" gorm:"-"`
DailyActivity []DailyActivity `json:"dailyActivity" gorm:"-"` DailyActivity []DailyActivity `json:"dailyActivity" gorm:"-"`
RecentSessions []RecentSession `json:"recentSessions" gorm:"-"` RecentSessions []RecentSession `json:"recentSessions" gorm:"-"`
} }
type RecentSession struct { type RecentSession struct {
ID uint `json:"id"` ID uuid.UUID `json:"id"`
Date string `json:"date"` Date string `json:"date"`
Type string `json:"type"` Type string `json:"type"`
Track string `json:"track"` Track string `json:"track"`
Duration int `json:"duration"` Duration int `json:"duration"`
Players int `json:"players"` Players int `json:"players"`
} }

View File

@@ -187,7 +187,7 @@ func (r *StateHistoryRepository) GetRecentSessions(ctx context.Context, filter *
FROM state_histories FROM state_histories
WHERE server_id = ? AND date_created BETWEEN ? AND ? WHERE server_id = ? AND date_created BETWEEN ? AND ?
GROUP BY session_id GROUP BY session_id
HAVING COUNT(*) > 1 AND MAX(player_count) > 0 HAVING MAX(player_count) > 0
ORDER BY date DESC ORDER BY date DESC
LIMIT 10 LIMIT 10
` `

View File

@@ -35,15 +35,9 @@ func NewSteamService(repository *repository.SteamCredentialsRepository, tfaManag
LogOutput: true, LogOutput: true,
} }
// Create a separate executor for SteamCMD that doesn't use PowerShell
steamCMDExecutor := &command.CommandExecutor{
ExePath: env.GetSteamCMDPath(),
LogOutput: true,
}
return &SteamService{ return &SteamService{
executor: baseExecutor, executor: baseExecutor,
interactiveExecutor: command.NewInteractiveCommandExecutor(steamCMDExecutor, tfaManager), interactiveExecutor: command.NewInteractiveCommandExecutor(baseExecutor, tfaManager),
repository: repository, repository: repository,
tfaManager: tfaManager, tfaManager: tfaManager,
pathValidator: security.NewPathValidator(), pathValidator: security.NewPathValidator(),
@@ -127,27 +121,36 @@ func (s *SteamService) InstallServer(ctx context.Context, installPath string, se
return fmt.Errorf("failed to get Steam credentials: %v", err) return fmt.Errorf("failed to get Steam credentials: %v", err)
} }
// Build SteamCMD command (no PowerShell args needed since we call SteamCMD directly) // Get SteamCMD path from environment variable
args := []string{ steamCMDPath := env.GetSteamCMDPath()
// Build SteamCMD command arguments
steamCMDArgs := []string{
"+force_install_dir", absPath, "+force_install_dir", absPath,
"+login", "+login",
} }
if creds != nil && creds.Username != "" { if creds != nil && creds.Username != "" {
args = append(args, creds.Username) steamCMDArgs = append(steamCMDArgs, creds.Username)
if creds.Password != "" { if creds.Password != "" {
args = append(args, creds.Password) steamCMDArgs = append(steamCMDArgs, creds.Password)
} }
} else { } else {
args = append(args, "anonymous") steamCMDArgs = append(steamCMDArgs, "anonymous")
} }
args = append(args, steamCMDArgs = append(steamCMDArgs,
"+app_update", ACCServerAppID, "+app_update", ACCServerAppID,
"validate", "validate",
"+quit", "+quit",
) )
// Build PowerShell arguments to execute SteamCMD directly
// This matches the format: powershell -nologo -noprofile c:\steamcmd\steamcmd.exe +args...
args := []string{"-nologo", "-noprofile"}
args = append(args, steamCMDPath)
args = append(args, steamCMDArgs...)
// Use interactive executor to handle potential 2FA prompts with timeout // Use interactive executor to handle potential 2FA prompts with timeout
logging.Info("Installing ACC server to %s...", absPath) logging.Info("Installing ACC server to %s...", absPath)

View File

@@ -360,7 +360,7 @@ func (m *MockStateHistoryRepository) GetRecentSessions(ctx context.Context, filt
if maxPlayers > 0 { if maxPlayers > 0 {
duration := int(maxDate.Sub(minDate).Minutes()) duration := int(maxDate.Sub(minDate).Minutes())
recentSessions = append(recentSessions, model.RecentSession{ recentSessions = append(recentSessions, model.RecentSession{
ID: uint(count + 1), ID: entries[0].SessionID,
Date: minDate.Format("2006-01-02 15:04:05"), Date: minDate.Format("2006-01-02 15:04:05"),
Type: entries[0].Session, Type: entries[0].Session,
Track: entries[0].Track, Track: entries[0].Track,