improve on the subimsion process with automatic submissions

make sure we give each user uniqe id
This commit is contained in:
Robin Olsen
2026-03-09 13:23:46 +01:00
parent d7c52383be
commit 5c4ecc841c
12 changed files with 319 additions and 184 deletions

View File

@@ -7,6 +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"
)
type App = models.App
@@ -42,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: 0,
ID: primitive.NewObjectID(),
StartTime: time.Now(),
})

View File

@@ -9,6 +9,7 @@ import (
"github.com/LazyBachelor/LazyPM/internal/models"
"github.com/LazyBachelor/LazyPM/internal/storage"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type StatisticsService struct {
@@ -42,6 +43,16 @@ func (s *StatisticsService) GetStatistics() (models.Statistics, error) {
return *s.storage.Data, nil
}
func (s *StatisticsService) GetParticipantID() primitive.ObjectID {
s.mu.Lock()
defer s.mu.Unlock()
if s.storage.Data == nil {
return primitive.NilObjectID
}
return s.storage.Data.ID
}
func (s *StatisticsService) RecordTaskRun(ctx context.Context, run models.TaskRunMetrics) error {
_ = ctx