learningequality / learningequality/studio

Run revert using `bulkPut`

Open
#1,883 1 comment 0 reactions 1 assignee View on GitHub

@bjester is already working on this.

Since May 11, 2020.

DEV: frontend P2 - normal TAG: performance
Dominant language
Python
Stars
191
Forks
307
Avg merge
5d 6h
Merged PRs (30d)
10

Description

Summary

See @rtibbles comment here

Suggested update:

const deleteableChanges = changes.filter(change => {
  return (
              change.type === CHANGE_TYPES.CREATED ||
              change.type === CHANGE_TYPES.COPIED ||
              (change.type === CHANGE_TYPES.MOVED && !change.oldObj)
  );
});

const bulkPutableChanges = changes.filter(change => {
  return (
              change.type === CHANGE_TYPES.UPDATED ||
              change.type === CHANGE_TYPES.DELETED ||
              (change.type === CHANGE_TYPES.MOVED && change.oldObj)
  );
});

const promises = [];

promises.push(table
  .where(table.schema.primKey.keyPath)
  .anyOf(deletableChanges.map(change => change.key))
  .delete());

promises.push(table.bulkPut(bulkPutableChanges.map(change => change.oldObj)));

return Promise.all(promises);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.