Skip to content

Commit

Permalink
[ontology/search] - added explicit not found check to ontology search…
Browse files Browse the repository at this point in the history
… query
  • Loading branch information
emilbon99 committed Aug 16, 2024
1 parent 4017abc commit acaa5bb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
2 changes: 2 additions & 0 deletions console/src/range/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export const { actions, reducer } = createSlice({
});
},
remove: (state, { payload: { keys } }: PA<RemovePayload>) => {
if (state.activeRange != null && keys.includes(state.activeRange))
state.activeRange = null;
keys.forEach((k) => delete state.ranges[k]);
},
setActive: (state, { payload }: PA<SetActivePayload>) => {
Expand Down
2 changes: 1 addition & 1 deletion pluto/src/channel/LinePlot.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
border: var(--pluto-border);
border-color: var(--haul-border-color);
border-radius: var(--pluto-border-radius);
}
}
4 changes: 2 additions & 2 deletions pluto/src/haul/Haul.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
*/

html {
--haul-background: var(--pluto-primary-z-40);
--haul-border-color: var(--pluto-primary-z-80);
--haul-background: var(--pluto-gray-l7-20);
--haul-border-color: var(--pluto-gray-l7-50);
}
8 changes: 6 additions & 2 deletions synnax/pkg/distribution/ontology/ontology.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,12 @@ func (o *Ontology) Search(ctx context.Context, req search.Request) ([]Resource,
if err != nil {
return nil, err
}
var resources []Resource
return resources, o.NewRetrieve().WhereIDs(ids...).Entries(&resources).Exec(ctx, o.DB)
resources := make([]Resource, 0, len(ids))
err = o.NewRetrieve().WhereIDs(ids...).Entries(&resources).Exec(ctx, o.DB)
if errors.Is(err, query.NotFound) {
err = nil
}
return resources, err
}

func (o *Ontology) SearchIDs(ctx context.Context, req search.Request) ([]ID, error) {
Expand Down
18 changes: 9 additions & 9 deletions synnax/pkg/distribution/ontology/retrieve.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,11 @@ func (r Retrieve) Exec(ctx context.Context, tx gorp.Tx) error {
if i != 0 {
clause.WhereKeys(nextIDs...)
}
if err := clause.Exec(ctx, tx); err != nil {
return err
}
cErr := clause.Exec(ctx, tx)
atLast := len(r.query.Clauses) == i+1
resources, err := r.retrieveEntities(ctx, clause, tx)
if err != nil || len(resources) == 0 || atLast {
return err
if cErr != nil || err != nil || len(resources) == 0 || atLast {
return errors.CombineErrors(cErr, err)
}
if nextIDs, err = r.traverse(
ctx,
Expand Down Expand Up @@ -220,10 +218,12 @@ func (r Retrieve) retrieveEntities(
clause gorp.Retrieve[ID, Resource],
tx gorp.Tx,
) ([]Resource, error) {
entries := gorp.GetEntries[ID, Resource](clause.Params)
excludeFieldData := getExcludeFieldData(clause.Params)
includeSchema := getIncludeSchema(clause.Params)
retrieveResource := (!excludeFieldData) || includeSchema
var (
entries = gorp.GetEntries[ID, Resource](clause.Params)
excludeFieldData = getExcludeFieldData(clause.Params)
includeSchema = getIncludeSchema(clause.Params)
retrieveResource = (!excludeFieldData) || includeSchema
)
// Iterate over the entries in place, retrieving the resource if the query requires it.
err := entries.MapInPlace(func(res Resource) (Resource, bool, error) {
if res.ID.IsZero() {
Expand Down

0 comments on commit acaa5bb

Please sign in to comment.