Files
PriceForge/internal/tasks/task.go
Mikhail Chusavitin 9fde087d0a Wire competitor models, task type, usage count fix, and Competitors page handler
- Register Competitor + CompetitorQuote in AllModels()
- Add TaskTypeCompetitorImport task type constant
- CountUsage now checks pricelist_id, warehouse_pricelist_id, competitor_pricelist_id
- WebHandler: load competitors.html template, add Competitors() page handler

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 09:00:07 +03:00

37 lines
1.2 KiB
Go

package tasks
import "time"
// TaskStatus represents the current status of a task
type TaskStatus string
const (
TaskStatusRunning TaskStatus = "running"
TaskStatusCompleted TaskStatus = "completed"
TaskStatusError TaskStatus = "error"
)
// TaskType represents the type of background task
type TaskType string
const (
TaskTypeRecalculate TaskType = "recalculate"
TaskTypeStockImport TaskType = "stock_import"
TaskTypePricelistCreate TaskType = "pricelist_create"
TaskTypePartnumberBookCreate TaskType = "partnumber_book_create"
TaskTypeCompetitorImport TaskType = "competitor_import"
)
// Task represents a background task with progress tracking
type Task struct {
ID string `json:"id"`
Type TaskType `json:"type"`
Status TaskStatus `json:"status"`
Progress int `json:"progress"` // 0-100
Message string `json:"message"`
Result map[string]interface{} `json:"result,omitempty"`
Error string `json:"error,omitempty"`
CreatedAt time.Time `json:"created_at"`
DoneAt *time.Time `json:"done_at,omitempty"`
}