-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #246 from pixlise/feature/quant-tracker
Feature/quant tracker
- Loading branch information
Showing
9 changed files
with
104 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,53 @@ | ||
package wsHandler | ||
|
||
import ( | ||
"errors" | ||
protos "github.com/pixlise/core/v4/generated-protos" | ||
"context" | ||
|
||
"github.com/pixlise/core/v4/api/dbCollections" | ||
"github.com/pixlise/core/v4/api/ws/wsHelpers" | ||
protos "github.com/pixlise/core/v4/generated-protos" | ||
"go.mongodb.org/mongo-driver/bson" | ||
"go.mongodb.org/mongo-driver/mongo/options" | ||
) | ||
|
||
func HandleJobListReq(req *protos.JobListReq, hctx wsHelpers.HandlerContext) (*protos.JobListResp, error) { | ||
return nil, errors.New("HandleJobListReq not implemented yet") | ||
// Work out if requestor is an admin or a normal user | ||
isAdmin := hctx.SessUser.Permissions["PIXLISE_ADMIN"] | ||
|
||
/*filter, _, err := wsHelpers.MakeFilter(req.SearchParams, false, protos.ObjectType_OT_QUANTIFICATION, hctx) | ||
if err != nil { | ||
return nil, err | ||
}*/ | ||
filter := bson.M{} | ||
|
||
ctx := context.TODO() | ||
coll := hctx.Svcs.MongoDB.Collection(dbCollections.JobStatusName) | ||
opts := options.Find() | ||
|
||
cursor, err := coll.Find(ctx, filter, opts) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
items := []*protos.JobStatus{} | ||
err = cursor.All(ctx, &items) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
itemsToSend := []*protos.JobStatus{} | ||
if isAdmin { | ||
itemsToSend = items | ||
} else { | ||
// Find only the jobs that were requested by this user | ||
for _, item := range items { | ||
if item.RequestorUserId == hctx.SessUser.User.Id { | ||
itemsToSend = append(itemsToSend, item) | ||
} | ||
} | ||
} | ||
|
||
return &protos.JobListResp{ | ||
Jobs: itemsToSend, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters