feat(javascript): add replaceAllObjectsWithTransformation#5008
feat(javascript): add replaceAllObjectsWithTransformation#5008
replaceAllObjectsWithTransformation#5008Conversation
142a5c0 to
bc5ed6c
Compare
✔️ Code generated!
📊 Benchmark resultsBenchmarks performed on the method using a mock server, the results might not reflect the real-world performance.
|
bc5ed6c to
405c5e4
Compare
ah actually that would mean breaking the signature, I need to check if there is some usage first |
0ee2dc0 to
4be66cf
Compare
breaking all of them at once in #5011 |
templates/javascript/clients/algoliasearch/builds/definition.mustache
Outdated
Show resolved
Hide resolved
| * @param chunkedPush.indexName - The `indexName` to replace `objects` in. | ||
| * @param chunkedPush.objects - The array of `objects` to store in the given Algolia `indexName`. | ||
| * @param chunkedPush.action - The `batch` `action` to perform on the given array of `objects`, defaults to `addObject`. | ||
| * @param chunkedPush.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable. |
There was a problem hiding this comment.
does waitForTasks make sense here ? should it be waitForPush ?
There was a problem hiding this comment.
I copied chunkedBatch so it's usable the same way but since it's internal I can rename it if you want
| const responses: Array<WatchResponse> = []; | ||
|
|
||
| const objectEntries = objects.entries(); | ||
| for (const [i, obj] of objectEntries) { |
There was a problem hiding this comment.
what about https://stackoverflow.com/a/8495740 ? I feel like it's more efficient and more readable
There was a problem hiding this comment.
I've actually just copied chunkedBatch 🥶
There was a problem hiding this comment.
I don't think it's IE compatible as well? I can't remember what version we should support but I think it's 11?
There was a problem hiding this comment.
slice is available everywhere
There was a problem hiding this comment.
i'll update both implems in a follow up pr!
| if (waitForTasks) { | ||
| for (const resp of responses) { | ||
| if (resp.eventID === undefined || !resp.eventID) { | ||
| throw new Error('received unexpected response from the push endpoint, eventID must not be undefined'); |
There was a problem hiding this comment.
IMO this error checking should be in loop above, to early exit.
Also in that case there should be an error message in the response
There was a problem hiding this comment.
I actually had to put it here to satisfy the type checking (same for Go and other languages), I can duplicate it, but this one is required
templates/javascript/clients/algoliasearch/builds/definition.mustache
Outdated
Show resolved
Hide resolved
templates/javascript/clients/algoliasearch/builds/definition.mustache
Outdated
Show resolved
Hide resolved
…generated) [skip ci] Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
algolia/api-clients-automation#5008 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
algolia/api-clients-automation#5008 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
algolia/api-clients-automation#5008 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
algolia/api-clients-automation#5008 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
algolia/api-clients-automation#5008 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
algolia/api-clients-automation#5008 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
algolia/api-clients-automation#5008 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
algolia/api-clients-automation#5008 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
algolia/api-clients-automation#5008 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
algolia/api-clients-automation#5008 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
algolia/api-clients-automation#5008 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
🧭 What and Why
🎟 JIRA Ticket: https://algolia.atlassian.net/browse/DI-3894
Changes included:
this adds the helper to replace all of the content of an index by leveraging the transformation pipeline, i've inlined the chunkedPush logic but actually could be reused in the saveObjects and partialUpdateObjects methods as well, lmk