-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Features/entities/auto convert sub to entities (#870)
* enhance: PATCH datasets/:name can now auto convert pending submissions into entity * use loop instead of recursion in runSequentially * correct SQL query * fix: event.details.data can be null dataset update worker * use entity source table * correct event id and save parent event id in source table * added assertion for audit of auto-created entity * lint it
- Loading branch information
1 parent
b7fc414
commit e9dba19
Showing
9 changed files
with
312 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2023 ODK Central Developers | ||
// See the NOTICE file at the top-level directory of this distribution and at | ||
// https://github.com/getodk/central-backend/blob/master/NOTICE. | ||
// This file is part of ODK Central. It is subject to the license terms in | ||
// the LICENSE file found in the top-level directory of this distribution and at | ||
// https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central, | ||
// including this file, may be copied, modified, propagated, or distributed | ||
// except according to the terms contained in the LICENSE file. | ||
|
||
const { getOrNotFound } = require('../util/promise'); | ||
|
||
const createEntitiesFromPendingSubmissions = async ({ Entities, Datasets }, event) => { | ||
if (event.details.data && !event.details.data.approvalRequired && event.details.autoConvert) { | ||
const dataset = await Datasets.getByActeeId(event.acteeId).then(getOrNotFound); | ||
const pendingSubmissions = await Datasets.getUnprocessedSubmissions(dataset.id); | ||
|
||
await Entities.createEntitiesFromPendingSubmissions(pendingSubmissions, event); | ||
} | ||
}; | ||
|
||
module.exports = { createEntitiesFromPendingSubmissions }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.