improve on the subimsion process with automatic submissions
make sure we give each user uniqe id
This commit is contained in:
@@ -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(),
|
||||
})
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user