完善一键回归与真实输入准备
This commit is contained in:
@@ -23,6 +23,7 @@ type DemoBootstrapSummary struct {
|
||||
VariantManualEventID string `json:"variantManualEventId"`
|
||||
VariantManualRelease string `json:"variantManualReleaseId"`
|
||||
VariantManualCardID string `json:"variantManualCardId"`
|
||||
CleanedSessionCount int64 `json:"cleanedSessionCount"`
|
||||
}
|
||||
|
||||
func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, error) {
|
||||
@@ -597,6 +598,23 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
return nil, fmt.Errorf("ensure variant manual demo card: %w", err)
|
||||
}
|
||||
|
||||
var cleanedSessionCount int64
|
||||
if err := tx.QueryRow(ctx, `
|
||||
WITH cleaned AS (
|
||||
UPDATE game_sessions
|
||||
SET
|
||||
status = 'cancelled',
|
||||
ended_at = NOW(),
|
||||
updated_at = NOW()
|
||||
WHERE event_id = ANY($1::uuid[])
|
||||
AND status IN ('launched', 'running')
|
||||
RETURNING 1
|
||||
)
|
||||
SELECT COUNT(*) FROM cleaned
|
||||
`, []string{eventID, manualEventID}).Scan(&cleanedSessionCount); err != nil {
|
||||
return nil, fmt.Errorf("cleanup demo ongoing sessions: %w", err)
|
||||
}
|
||||
|
||||
if err := tx.Commit(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -619,5 +637,6 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
VariantManualEventID: "evt_demo_variant_manual_001",
|
||||
VariantManualRelease: manualReleaseRow.PublicID,
|
||||
VariantManualCardID: manualCardPublicID,
|
||||
CleanedSessionCount: cleanedSessionCount,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user