-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from OpenFn/214-deployed-to-archived
Update sheet `status` and `date_modified` column
- Loading branch information
Showing
4 changed files
with
77 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
getValues( | ||
"1s7K3kxzm5AlpwiALattyc7D9_aIyqWmo2ubcQIUlqlY", //googlesheet id | ||
"wcs-bns-test!A:L" //range of columns in sheet | ||
'1s7K3kxzm5AlpwiALattyc7D9_aIyqWmo2ubcQIUlqlY', //googlesheet id | ||
'wcs-bns-test!A:N' //range of columns in sheet | ||
); | ||
|
||
fn((state) => { | ||
const { koboForms, data } = state; | ||
fn(state => { | ||
const { activeForms, archivedForms, data } = state; | ||
const [headers, ...sheetsData] = data.values; | ||
const sheetsUids = sheetsData.map((row) => row[0]); | ||
console.log("Ignoring headers", headers); | ||
const sheetsUids = sheetsData.map(row => row[0]); | ||
console.log('Ignoring headers', headers); | ||
|
||
state.filteredKoboFormsData = koboForms.filter( | ||
(form) => !sheetsUids.includes(form.uid) | ||
state.formsToCreate = activeForms.filter( | ||
form => !sheetsUids.includes(form.uid) | ||
); | ||
state.data = {}; | ||
state.references = []; | ||
|
||
state.formsToUpdate = archivedForms | ||
.filter(form => sheetsUids.includes(form.uid)) | ||
.map(form => { | ||
const rowIndex = sheetsData.findIndex(row => { | ||
return row[0] === form.uid; | ||
}); | ||
if (rowIndex !== -1) { | ||
return { ...form, rowIndex }; | ||
} | ||
console.log(form.uid, 'Could not be found in google sheet'); | ||
}); | ||
|
||
return state; | ||
}); | ||
|
||
fn(state => { | ||
const { data, references, response, ...remainingState } = state; | ||
|
||
return remainingState; | ||
}); |
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