upgrade mongodb driver dep
This commit is contained in:
1
go.mod
1
go.mod
@@ -7,7 +7,6 @@ require (
|
|||||||
github.com/joho/godotenv v1.5.1
|
github.com/joho/godotenv v1.5.1
|
||||||
github.com/muesli/reflow v0.3.0
|
github.com/muesli/reflow v0.3.0
|
||||||
github.com/steveyegge/beads v0.49.6
|
github.com/steveyegge/beads v0.49.6
|
||||||
go.mongodb.org/mongo-driver v1.17.9
|
|
||||||
go.mongodb.org/mongo-driver/v2 v2.5.0
|
go.mongodb.org/mongo-driver/v2 v2.5.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
2
go.sum
2
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 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
|
||||||
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
|
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=
|
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 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE=
|
||||||
go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
|
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=
|
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
"github.com/LazyBachelor/LazyPM/internal/storage"
|
"github.com/LazyBachelor/LazyPM/internal/storage"
|
||||||
"github.com/steveyegge/beads"
|
"github.com/steveyegge/beads"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/v2/bson"
|
||||||
)
|
)
|
||||||
|
|
||||||
type App = models.App
|
type App = models.App
|
||||||
@@ -43,7 +43,7 @@ func New(ctx context.Context, config Config, opts ...Option) (*App, func(), erro
|
|||||||
|
|
||||||
if b.statsService == nil {
|
if b.statsService == nil {
|
||||||
statStore := storage.NewJsonStorage(config.StatisticsStoragePath, &models.Statistics{
|
statStore := storage.NewJsonStorage(config.StatisticsStoragePath, &models.Statistics{
|
||||||
ID: primitive.NewObjectID(),
|
ID: bson.NewObjectID(),
|
||||||
StartTime: time.Now(),
|
StartTime: time.Now(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
"github.com/LazyBachelor/LazyPM/internal/storage"
|
"github.com/LazyBachelor/LazyPM/internal/storage"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/v2/bson"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StatisticsService struct {
|
type StatisticsService struct {
|
||||||
@@ -43,12 +43,12 @@ func (s *StatisticsService) GetStatistics() (models.Statistics, error) {
|
|||||||
return *s.storage.Data, nil
|
return *s.storage.Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StatisticsService) GetParticipantID() primitive.ObjectID {
|
func (s *StatisticsService) GetParticipantID() bson.ObjectID {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
|
|
||||||
if s.storage.Data == nil {
|
if s.storage.Data == nil {
|
||||||
return primitive.NilObjectID
|
return bson.NilObjectID
|
||||||
}
|
}
|
||||||
return s.storage.Data.ID
|
return s.storage.Data.ID
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/v2/bson"
|
||||||
)
|
)
|
||||||
|
|
||||||
type App struct {
|
type App struct {
|
||||||
@@ -59,7 +59,7 @@ type StatsService interface {
|
|||||||
Load(ctx context.Context) error
|
Load(ctx context.Context) error
|
||||||
Save(ctx context.Context) error
|
Save(ctx context.Context) error
|
||||||
GetStatistics() (Statistics, error)
|
GetStatistics() (Statistics, error)
|
||||||
GetParticipantID() primitive.ObjectID
|
GetParticipantID() bson.ObjectID
|
||||||
RecordTaskRun(ctx context.Context, run TaskRunMetrics) error
|
RecordTaskRun(ctx context.Context, run TaskRunMetrics) error
|
||||||
RecordIntroQuestionnaireAnswers(answers map[string]any) error
|
RecordIntroQuestionnaireAnswers(answers map[string]any) error
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ package models
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/v2/bson"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Statistics struct {
|
type Statistics struct {
|
||||||
ID primitive.ObjectID `bson:"_id" json:"id"`
|
ID bson.ObjectID `bson:"_id" json:"id"`
|
||||||
StartTime time.Time `bson:"start_time" json:"start_time"`
|
StartTime time.Time `bson:"start_time" json:"start_time"`
|
||||||
EndTime time.Time `bson:"end_time" json:"end_time"`
|
EndTime time.Time `bson:"end_time" json:"end_time"`
|
||||||
DurationMs int64 `bson:"duration_ms" json:"duration_ms"`
|
DurationMs int64 `bson:"duration_ms" json:"duration_ms"`
|
||||||
|
|
||||||
LastInterfaceType InterfaceType `bson:"last_interface_type" json:"last_interface_type"`
|
LastInterfaceType InterfaceType `bson:"last_interface_type" json:"last_interface_type"`
|
||||||
TaskRuns int `bson:"task_runs" json:"task_runs"`
|
TaskRuns int `bson:"task_runs" json:"task_runs"`
|
||||||
@@ -38,12 +38,12 @@ type Statistics struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TaskMetricsFile struct {
|
type TaskMetricsFile struct {
|
||||||
ID primitive.ObjectID `bson:"_id" json:"id"`
|
ID bson.ObjectID `bson:"_id" json:"id"`
|
||||||
ParticipantID primitive.ObjectID `bson:"participant_id" json:"participant_id"`
|
ParticipantID bson.ObjectID `bson:"participant_id" json:"participant_id"`
|
||||||
TaskName string `bson:"task_name" json:"task_name"`
|
TaskName string `bson:"task_name" json:"task_name"`
|
||||||
UpdatedAt time.Time `bson:"updated_at" json:"updated_at"`
|
UpdatedAt time.Time `bson:"updated_at" json:"updated_at"`
|
||||||
Summary TaskStatsSummary `bson:"summary" json:"summary"`
|
Summary TaskStatsSummary `bson:"summary" json:"summary"`
|
||||||
Runs []TaskRunMetrics `bson:"runs" json:"runs"`
|
Runs []TaskRunMetrics `bson:"runs" json:"runs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TaskStatsSummary struct {
|
type TaskStatsSummary struct {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/v2/bson"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RunLifecycle struct {
|
type RunLifecycle struct {
|
||||||
@@ -24,7 +24,7 @@ func NewRunLifecycle(app *App, config Config, details models.TaskDetails, iType
|
|||||||
collector.recordUserAction(action)
|
collector.recordUserAction(action)
|
||||||
})
|
})
|
||||||
|
|
||||||
var participantID primitive.ObjectID
|
var participantID bson.ObjectID
|
||||||
var store MetricsStore
|
var store MetricsStore
|
||||||
if config.StatisticsStoragePath != "" {
|
if config.StatisticsStoragePath != "" {
|
||||||
participantID = app.Stats.GetParticipantID()
|
participantID = app.Stats.GetParticipantID()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/v2/bson"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MetricsStore interface {
|
type MetricsStore interface {
|
||||||
@@ -19,11 +19,11 @@ type MetricsStore interface {
|
|||||||
|
|
||||||
type FileMetricsStore struct {
|
type FileMetricsStore struct {
|
||||||
path string
|
path string
|
||||||
participantID primitive.ObjectID
|
participantID bson.ObjectID
|
||||||
logger *slog.Logger
|
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{
|
return &FileMetricsStore{
|
||||||
path: path,
|
path: path,
|
||||||
participantID: participantID,
|
participantID: participantID,
|
||||||
@@ -44,7 +44,7 @@ func (s *FileMetricsStore) Append(ctx context.Context, taskName string, run mode
|
|||||||
}
|
}
|
||||||
|
|
||||||
metrics := models.TaskMetricsFile{
|
metrics := models.TaskMetricsFile{
|
||||||
ID: primitive.NewObjectID(),
|
ID: bson.NewObjectID(),
|
||||||
ParticipantID: s.participantID,
|
ParticipantID: s.participantID,
|
||||||
TaskName: taskName,
|
TaskName: taskName,
|
||||||
Runs: []models.TaskRunMetrics{},
|
Runs: []models.TaskRunMetrics{},
|
||||||
|
|||||||
Reference in New Issue
Block a user