Skip to content

Commit

Permalink
Improve model search
Browse files Browse the repository at this point in the history
  • Loading branch information
a3957273 committed Apr 2, 2024
1 parent 71b4c33 commit 3b620a9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions backend/src/services/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,16 @@ export async function searchModels(
}
}

const results = await ModelModel
let cursor = ModelModel
// Find only matching documents
.find(query)

if (!search)
// Sort by last updated
.sort({ updatedAt: -1 })
cursor = cursor.sort({ updatedAt: -1 })
}

const results = await cursor

const auths = await authorisation.models(user, results, ModelAction.View)
return results.filter((_, i) => auths[i].success)
Expand Down

0 comments on commit 3b620a9

Please sign in to comment.