diff --git a/go.mod b/go.mod index ee97108..823223e 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/joho/godotenv v1.5.1 github.com/muesli/reflow v0.3.0 github.com/steveyegge/beads v0.49.6 - go.mongodb.org/mongo-driver v1.17.9 go.mongodb.org/mongo-driver/v2 v2.5.0 ) diff --git a/go.sum b/go.sum index 18ba4da..1dc87ce 100644 --- a/go.sum +++ b/go.sum @@ -241,8 +241,6 @@ github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3i github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver v1.17.9 h1:IexDdCuuNJ3BHrELgBlyaH9p60JXAvdzWR128q+U5tU= -go.mongodb.org/mongo-driver v1.17.9/go.mod h1:LlOhpH5NUEfhxcAwG0UEkMqwYcc4JU18gtCdGudk/tQ= go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE= go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= diff --git a/internal/app/app.go b/internal/app/app.go index 1ee6aa2..ace5983 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -7,7 +7,7 @@ import ( "github.com/LazyBachelor/LazyPM/internal/models" "github.com/LazyBachelor/LazyPM/internal/storage" "github.com/steveyegge/beads" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) type App = models.App @@ -43,7 +43,7 @@ func New(ctx context.Context, config Config, opts ...Option) (*App, func(), erro if b.statsService == nil { statStore := storage.NewJsonStorage(config.StatisticsStoragePath, &models.Statistics{ - ID: primitive.NewObjectID(), + ID: bson.NewObjectID(), StartTime: time.Now(), }) diff --git a/internal/app/statistics.go b/internal/app/statistics.go index abd12a6..bd594c5 100644 --- a/internal/app/statistics.go +++ b/internal/app/statistics.go @@ -9,7 +9,7 @@ import ( "github.com/LazyBachelor/LazyPM/internal/models" "github.com/LazyBachelor/LazyPM/internal/storage" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) type StatisticsService struct { @@ -43,12 +43,12 @@ func (s *StatisticsService) GetStatistics() (models.Statistics, error) { return *s.storage.Data, nil } -func (s *StatisticsService) GetParticipantID() primitive.ObjectID { +func (s *StatisticsService) GetParticipantID() bson.ObjectID { s.mu.Lock() defer s.mu.Unlock() if s.storage.Data == nil { - return primitive.NilObjectID + return bson.NilObjectID } return s.storage.Data.ID } diff --git a/internal/models/app.go b/internal/models/app.go index e1e5603..3736d60 100644 --- a/internal/models/app.go +++ b/internal/models/app.go @@ -4,7 +4,7 @@ import ( "context" "log/slog" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) type App struct { @@ -59,7 +59,7 @@ type StatsService interface { Load(ctx context.Context) error Save(ctx context.Context) error GetStatistics() (Statistics, error) - GetParticipantID() primitive.ObjectID + GetParticipantID() bson.ObjectID RecordTaskRun(ctx context.Context, run TaskRunMetrics) error RecordIntroQuestionnaireAnswers(answers map[string]any) error } diff --git a/internal/models/statistics.go b/internal/models/statistics.go index fe4c8df..ed81b9d 100644 --- a/internal/models/statistics.go +++ b/internal/models/statistics.go @@ -3,14 +3,14 @@ package models import ( "time" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) type Statistics struct { - ID primitive.ObjectID `bson:"_id" json:"id"` - StartTime time.Time `bson:"start_time" json:"start_time"` - EndTime time.Time `bson:"end_time" json:"end_time"` - DurationMs int64 `bson:"duration_ms" json:"duration_ms"` + ID bson.ObjectID `bson:"_id" json:"id"` + StartTime time.Time `bson:"start_time" json:"start_time"` + EndTime time.Time `bson:"end_time" json:"end_time"` + DurationMs int64 `bson:"duration_ms" json:"duration_ms"` LastInterfaceType InterfaceType `bson:"last_interface_type" json:"last_interface_type"` TaskRuns int `bson:"task_runs" json:"task_runs"` @@ -38,12 +38,12 @@ type Statistics struct { } type TaskMetricsFile struct { - ID primitive.ObjectID `bson:"_id" json:"id"` - ParticipantID primitive.ObjectID `bson:"participant_id" json:"participant_id"` - TaskName string `bson:"task_name" json:"task_name"` - UpdatedAt time.Time `bson:"updated_at" json:"updated_at"` - Summary TaskStatsSummary `bson:"summary" json:"summary"` - Runs []TaskRunMetrics `bson:"runs" json:"runs"` + ID bson.ObjectID `bson:"_id" json:"id"` + ParticipantID bson.ObjectID `bson:"participant_id" json:"participant_id"` + TaskName string `bson:"task_name" json:"task_name"` + UpdatedAt time.Time `bson:"updated_at" json:"updated_at"` + Summary TaskStatsSummary `bson:"summary" json:"summary"` + Runs []TaskRunMetrics `bson:"runs" json:"runs"` } type TaskStatsSummary struct { diff --git a/pkg/task/lifecycle.go b/pkg/task/lifecycle.go index 75b18d9..56063e2 100644 --- a/pkg/task/lifecycle.go +++ b/pkg/task/lifecycle.go @@ -4,7 +4,7 @@ import ( "log/slog" "github.com/LazyBachelor/LazyPM/internal/models" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) type RunLifecycle struct { @@ -24,7 +24,7 @@ func NewRunLifecycle(app *App, config Config, details models.TaskDetails, iType collector.recordUserAction(action) }) - var participantID primitive.ObjectID + var participantID bson.ObjectID var store MetricsStore if config.StatisticsStoragePath != "" { participantID = app.Stats.GetParticipantID() diff --git a/pkg/task/metrics_store.go b/pkg/task/metrics_store.go index a499de8..11ca88d 100644 --- a/pkg/task/metrics_store.go +++ b/pkg/task/metrics_store.go @@ -10,7 +10,7 @@ import ( "time" "github.com/LazyBachelor/LazyPM/internal/models" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) type MetricsStore interface { @@ -19,11 +19,11 @@ type MetricsStore interface { type FileMetricsStore struct { path string - participantID primitive.ObjectID + participantID bson.ObjectID logger *slog.Logger } -func NewFileMetricsStore(path string, participantID primitive.ObjectID, logger *slog.Logger) *FileMetricsStore { +func NewFileMetricsStore(path string, participantID bson.ObjectID, logger *slog.Logger) *FileMetricsStore { return &FileMetricsStore{ path: path, participantID: participantID, @@ -44,7 +44,7 @@ func (s *FileMetricsStore) Append(ctx context.Context, taskName string, run mode } metrics := models.TaskMetricsFile{ - ID: primitive.NewObjectID(), + ID: bson.NewObjectID(), ParticipantID: s.participantID, TaskName: taskName, Runs: []models.TaskRunMetrics{}, diff --git a/pkg/web/handler/issues.go b/pkg/web/handler/issues.go index 3f48bc1..5870316 100644 --- a/pkg/web/handler/issues.go +++ b/pkg/web/handler/issues.go @@ -62,7 +62,7 @@ func CreateIssue(w http.ResponseWriter, r *http.Request) { from := r.URL.Query().Get("from") referer := r.Header.Get("Referer") boardView := from == "board" || strings.Contains(referer, "board=true") - + if boardView { w.Header().Set("HX-Redirect", "/?board=true") } else { @@ -181,7 +181,7 @@ func UpdateIssue(w http.ResponseWriter, r *http.Request) { from := r.URL.Query().Get("from") referer := r.Header.Get("Referer") boardView := from == "board" || strings.Contains(referer, "board=true") - + if boardView { w.Header().Set("HX-Redirect", "/?board=true") } else { @@ -213,7 +213,7 @@ func UpdateAssignee(w http.ResponseWriter, r *http.Request) { // Check if we're in board view referer := r.Header.Get("Referer") boardView := strings.Contains(referer, "board=true") - + if boardView { w.Header().Set("HX-Redirect", "/?board=true&selected-issue="+issue.ID) } else { @@ -239,7 +239,7 @@ func DeleteIssue(w http.ResponseWriter, r *http.Request) { from := r.URL.Query().Get("from") referer := r.Header.Get("Referer") boardView := from == "board" || strings.Contains(referer, "board=true") - + if boardView { w.Header().Set("HX-Redirect", "/?board=true") } else {