Skip to content

Commit

Permalink
fix: transactions processed by row not in batch
Browse files Browse the repository at this point in the history
  • Loading branch information
Kpoke committed Nov 13, 2024
1 parent a974ef5 commit 1e4e19d
Show file tree
Hide file tree
Showing 30 changed files with 20 additions and 12 deletions.
Binary file not shown.
Binary file not shown.
Binary file added lib/__pycache__/capture_export.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added lib/__pycache__/earning_export.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file added lib/__pycache__/grower_exort_test.cpython-39.pyc
Binary file not shown.
Binary file added lib/__pycache__/grower_export.cpython-39.pyc
Binary file not shown.
Binary file added lib/__pycache__/leader_board.cpython-39.pyc
Binary file not shown.
Binary file added lib/__pycache__/leader_board_test.cpython-39.pyc
Binary file not shown.
Binary file added lib/__pycache__/messaging.cpython-39.pyc
Binary file not shown.
Binary file added lib/__pycache__/planter_entity.cpython-39.pyc
Binary file not shown.
Binary file added lib/__pycache__/planter_entity_test.cpython-39.pyc
Binary file not shown.
Binary file added lib/__pycache__/pre_request.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added lib/__pycache__/pre_request_test.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added lib/__pycache__/utils.cpython-39.pyc
Binary file not shown.
Binary file added lib/__pycache__/utils_test.cpython-39.pyc
Binary file not shown.
8 changes: 5 additions & 3 deletions v1Tov2Migrations/migrate_approved_captures.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ async function migrate() {
{ width: 40, total: recordCount },
);

const trx = await knex.transaction();
ws._write = async (rawCapture, enc, next) => {
console.log('processing ', rawCapture.id);
const trx = await knex.transaction();
try {
const tree = await trx
.select()
Expand All @@ -61,12 +62,13 @@ async function migrate() {
[+tree.id],
);

console.log('migrating ', tree.id)
console.log('migrating ', tree.id);
await createCapture(rawCapture, tree, trx, treeTags.rows);

await trx.commit();
console.log('processed ', rawCapture.id);
bar.tick();
if (bar.complete) {
await trx.commit();
console.log('Migration Complete');
process.exit();
}
Expand Down
7 changes: 4 additions & 3 deletions v1Tov2Migrations/migrate_raw_captures.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ async function migrate() {
{ width: 40, total: recordCount },
);

const trx = await knex.transaction();
ws._write = async (tree, enc, next) => {
console.log('processing ', tree.id);
const trx = await knex.transaction();
try {
console.log('processing ', tree.id);
const planter = await trx
.select()
.table('public.planter')
Expand Down Expand Up @@ -137,9 +137,10 @@ async function migrate() {

await createRawCapture(tree, treeAttributes, sessionId, trx);

await trx.commit();
console.log('processed ', tree.id);
bar.tick();
if (bar.complete) {
await trx.commit();
console.log('Migration Complete');
process.exit();
}
Expand Down
17 changes: 11 additions & 6 deletions v1Tov2Migrations/migrate_trees.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ async function migrate() {
}
console.log(`Migrating ${recordCount} records`);

const bar = new ProgressBar('Migrating [:bar] :percent :etas :current/:total (:rate)', {
width: 40,
total: recordCount,
});
const bar = new ProgressBar(
'Migrating [:bar] :percent :etas :current/:total (:rate)',
{
width: 40,
total: recordCount,
},
);

const trx = await knex.transaction();
ws._write = async (capture, enc, next) => {
console.log('processing ', capture.id);
const trx = await knex.transaction();
try {
// migrate capture_tags as well, do we want to?
const captureTags = await trx.raw(
Expand All @@ -43,9 +47,10 @@ async function migrate() {

await createTree(capture, trx, captureTags.rows);

await trx.commit();
console.log('processed ', capture.id);
bar.tick();
if (bar.complete) {
await trx.commit();
console.log('Migration Complete');
process.exit();
}
Expand Down

0 comments on commit 1e4e19d

Please sign in to comment.