diff options
author | bob <bcz@cs.brown.edu> | 2019-11-06 12:35:51 -0500 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-11-06 12:35:51 -0500 |
commit | f83205e4ea3486ebeeaa52918650bf6521c36cb9 (patch) | |
tree | 0f6e17b4621ad98e19e4dbb8a8dc6fe87df31eb5 /src/server/index.ts | |
parent | bcc45bf8d448e56935172398a52327c68ff6117e (diff) |
schema view cleanups
Diffstat (limited to 'src/server/index.ts')
-rw-r--r-- | src/server/index.ts | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/src/server/index.ts b/src/server/index.ts index 1595781dc..c6753a253 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -1049,34 +1049,42 @@ addSecureRoute({ let failed: number[] = []; - const batched = BatchedArray.from<GooglePhotosUploadUtils.MediaInput>(media, { batchSize: 25 }); - const newMediaItems = await batched.batchedMapPatientInterval<NewMediaItem>( - { magnitude: 100, unit: TimeUnit.Milliseconds }, - async (batch, collector) => { - for (let index = 0; index < batch.length; index++) { - const { url, description } = batch[index]; - const uploadToken = await GooglePhotosUploadUtils.DispatchGooglePhotosUpload(url); - if (!uploadToken) { - failed.push(index); - } else { - collector.push({ - description, - simpleMediaItem: { uploadToken } - }); - } - } - } - ); - - const failedCount = failed.length; - if (failedCount) { - console.error(`Unable to upload ${failedCount} image${failedCount === 1 ? "" : "s"} to Google's servers`); - } - - GooglePhotosUploadUtils.CreateMediaItems(newMediaItems, req.body.album).then( - results => _success(res, { results, failed }), - error => _error(res, mediaError, error) - ); + // bcz: this doesn't compile: + // Using ts-node version 7.0.1, typescript version 3.5.3 + // [ERROR] 09:54:48 тип Unable to compile TypeScript: + // src/server/index.ts(1055,13): error TS2345: Argument of type '(batch: MediaInput[], collector: BatchContext) => Promise<void>' is not assignable to parameter of type 'BatchFunction<MediaInput, NewMediaItem[] | Promise<NewMediaItem[]>>'. + // Type 'Promise<void>' is not assignable to type 'NewMediaItem[] | Promise<NewMediaItem[]>'. + // Type 'Promise<void>' is not assignable to type 'Promise<NewMediaItem[]>'. + // Type 'void' is not assignable to type 'NewMediaItem[]'. + // src/server/index.ts(1062,35): error TS2339: Property 'push' does not exist on type 'BatchContext'. + // const batched = BatchedArray.from<GooglePhotosUploadUtils.MediaInput>(media, { batchSize: 25 }); + // const newMediaItems = await batched.batchedMapPatientInterval<NewMediaItem>( + // { magnitude: 100, unit: TimeUnit.Milliseconds }, + // async (batch, collector) => { + // for (let index = 0; index < batch.length; index++) { + // const { url, description } = batch[index]; + // const uploadToken = await GooglePhotosUploadUtils.DispatchGooglePhotosUpload(url); + // if (!uploadToken) { + // failed.push(index); + // } else { + // collector.push({ + // description, + // simpleMediaItem: { uploadToken } + // }); + // } + // } + // } + // ); + + // const failedCount = failed.length; + // if (failedCount) { + // console.error(`Unable to upload ${failedCount} image${failedCount === 1 ? "" : "s"} to Google's servers`); + // } + + // GooglePhotosUploadUtils.CreateMediaItems(newMediaItems, req.body.album).then( + // results => _success(res, { results, failed }), + // error => _error(res, mediaError, error) + // ); } }); |