Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into alex/indexcleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Roukoswarf committed May 22, 2024
2 parents ca229a1 + d909b3a commit 9e0a314
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions data/store/mongo/mongo_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func (d *DataRepository) ListUserDataSets(ctx context.Context, userID string, fi
return d.DataSetRepository.ListUserDataSets(ctx, userID, filter, pagination)
}

func (d *DataRepository) GetDataSet(ctx context.Context, id string) (*data.DataSet, error) {
return d.DataSetRepository.GetDataSet(ctx, id)
func (d *DataRepository) GetDataSet(ctx context.Context, dataSetID string) (*data.DataSet, error) {
return d.DataSetRepository.GetDataSet(ctx, dataSetID)
}

func (d *DataRepository) GetDataSetByID(ctx context.Context, dataSetID string) (*upload.Upload, error) {
Expand Down
13 changes: 7 additions & 6 deletions data/store/mongo/mongo_data_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mongo

import (
"context"
stdErrs "errors"
"time"

"go.mongodb.org/mongo-driver/bson"
Expand Down Expand Up @@ -115,7 +116,7 @@ func (d *DataSetRepository) GetDataSetByID(ctx context.Context, dataSetID string
loggerFields := log.Fields{"dataSetId": dataSetID, "duration": time.Since(now) / time.Microsecond}
log.LoggerFromContext(ctx).WithFields(loggerFields).WithError(err).Debug("DataSet.GetDataSetByID")

if err == mongo.ErrNoDocuments {
if stdErrs.Is(err, mongo.ErrNoDocuments) {
return nil, nil
} else if err != nil {
return nil, errors.Wrap(err, "unable to get data set by id")
Expand Down Expand Up @@ -214,25 +215,25 @@ func (d *DataSetRepository) updateDataSet(ctx context.Context, id string, update
return d.GetDataSetByID(ctx, id)
}

func (d *DataSetRepository) GetDataSet(ctx context.Context, id string) (*data.DataSet, error) {
func (d *DataSetRepository) GetDataSet(ctx context.Context, dataSetID string) (*data.DataSet, error) {
if ctx == nil {
return nil, errors.New("context is missing")
}
if id == "" {
if dataSetID == "" {
return nil, errors.New("id is missing")
}

now := time.Now()
logger := log.LoggerFromContext(ctx).WithField("id", id)
logger := log.LoggerFromContext(ctx).WithField("id", dataSetID)

var dataSet *data.DataSet
selector := bson.M{
"uploadId": id,
"uploadId": dataSetID,
}

err := d.FindOne(ctx, selector).Decode(&dataSet)
logger.WithField("duration", time.Since(now)/time.Microsecond).WithError(err).Debug("DataSet.GetDataSet")
if err == mongo.ErrNoDocuments {
if stdErrs.Is(err, mongo.ErrNoDocuments) {
return nil, nil
} else if err != nil {
return nil, errors.Wrap(err, "unable to get data set")
Expand Down
3 changes: 2 additions & 1 deletion data/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type DataSetRepository interface {
DestroyDataForUserByID(ctx context.Context, userID string) error

ListUserDataSets(ctx context.Context, userID string, filter *data.DataSetFilter, pagination *page.Pagination) (data.DataSets, error)
GetDataSet(ctx context.Context, id string) (*data.DataSet, error)
GetDataSet(ctx context.Context, dataSetID string) (*data.DataSet, error)
}

// DatumRepository is the interface for interacting and modifying
Expand All @@ -59,6 +59,7 @@ type DatumRepository interface {
UnarchiveDeviceDataUsingHashesFromDataSet(ctx context.Context, dataSet *upload.Upload) error
DeleteOtherDataSetData(ctx context.Context, dataSet *upload.Upload) error
DestroyDataForUserByID(ctx context.Context, userID string) error
ListUserDataSets(ctx context.Context, userID string, filter *data.DataSetFilter, pagination *page.Pagination) (data.DataSets, error)

GetDataRange(ctx context.Context, userId string, typ string, status *types.UserLastUpdated) (*mongo.Cursor, error)
GetLastUpdatedForUser(ctx context.Context, userId string, typ string, lastUpdated time.Time) (*types.UserLastUpdated, error)
Expand Down

0 comments on commit 9e0a314

Please sign in to comment.