@openneuro/server 4.24.0-alpha.0 → 4.24.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openneuro/server",
3
- "version": "4.24.0-alpha.0",
3
+ "version": "4.24.0-alpha.2",
4
4
  "description": "Core service for the OpenNeuro platform.",
5
5
  "license": "MIT",
6
6
  "main": "src/server.js",
@@ -21,7 +21,7 @@
21
21
  "@elastic/elasticsearch": "8.13.1",
22
22
  "@graphql-tools/schema": "^10.0.0",
23
23
  "@keyv/redis": "^2.7.0",
24
- "@openneuro/search": "^4.24.0-alpha.0",
24
+ "@openneuro/search": "^4.24.0-alpha.2",
25
25
  "@passport-next/passport-google-oauth2": "^1.0.0",
26
26
  "@sentry/node": "^4.5.3",
27
27
  "base64url": "^3.0.0",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "4e271231c20d21e4c8b5ba8851d67cb94b7f739a"
89
+ "gitHead": "aa9717595d41e5e0eb55328c62fa59c80847b95e"
90
90
  }
@@ -4,6 +4,7 @@ import Star from "../../models/stars"
4
4
  import Subscription from "../../models/subscription"
5
5
  import Permission from "../../models/permission"
6
6
  import { hashObject } from "../../libs/authentication/crypto"
7
+ import util from "util"
7
8
 
8
9
  const elasticIndex = "datasets"
9
10
 
@@ -215,6 +216,7 @@ export const advancedDatasetSearchConnection = async (
215
216
  },
216
217
  { user, userInfo },
217
218
  ) => {
219
+ // Create an identity for this search (used to cache connections)
218
220
  const searchId = hashObject({
219
221
  query,
220
222
  datasetType,
@@ -223,28 +225,32 @@ export const advancedDatasetSearchConnection = async (
223
225
  user,
224
226
  })
225
227
  const sort = [{ _score: "desc" }, { id: "desc" }]
226
- if (sortBy) sort.unshift(sortBy)
227
- const requestBody = {
228
- sort,
229
- query: allDatasets
230
- ? query
231
- : await parseQuery(query, datasetType, datasetStatus, user),
232
- search_after: undefined,
228
+ if (sortBy) {
229
+ sort.unshift(sortBy)
233
230
  }
231
+ // Parse out the decode token and add it to our query if successful
232
+ let search_after
234
233
  if (after) {
235
234
  try {
236
- requestBody.search_after = decodeCursor(after)
237
- } catch (err) {
235
+ search_after = decodeCursor(after)
236
+ } catch (_err) {
238
237
  // Don't include search_after if parsing fails
239
238
  }
240
239
  }
241
- await elasticClient.search({
240
+ const requestBody = {
242
241
  index: elasticIndex,
243
242
  size: first,
244
- ...requestBody,
245
- })
243
+ sort,
244
+ query: allDatasets
245
+ ? query
246
+ : await parseQuery(query, datasetType, datasetStatus, user),
247
+ search_after,
248
+ }
249
+ // Run the query
250
+ const result = await elasticClient.search(requestBody)
251
+ // Extend with relay connection pagination
246
252
  return elasticRelayConnection(
247
- requestBody,
253
+ result,
248
254
  searchId,
249
255
  first,
250
256
  undefined,