Skip to content

Commit 74ed9ef

Browse files
author
Gareth Emslie
committed
refactor
1 parent 0da830c commit 74ed9ef

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

src/import-csv-discussions-action.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,21 @@ class ImportCSVDiscussionsAction implements IContributedMenuSource {
145145
// Loop through each record in this batch and generate the JSON
146146
batch.forEach(async (record: any) => {
147147
this._logger.debug("record", record);
148+
149+
/* batch_payload.push({
150+
"method": "PATCH",
151+
"uri": `/_apis/wit/workitems/${record.WorkItemId}?api-version=4.1`,
152+
"headers": {
153+
"Content-Type": "application/json-patch+json"
154+
},
155+
"body": [{
156+
"op": "add",
157+
"path": "/fields/System.History",
158+
"value": `${discussion_comment}`
159+
}
160+
]
161+
}); */
162+
148163
promises.push(this.createComment(`${hostBaseUrl}${project.name}/_apis/wit/workItems/${record.WorkItemId}/comments?api-version=6.0-preview.3`, accessToken, record));
149164
});
150165

@@ -167,7 +182,7 @@ class ImportCSVDiscussionsAction implements IContributedMenuSource {
167182
});
168183

169184
// wait for promises
170-
Promise.all(promises).then(()=>{
185+
await Promise.all(promises.map(p => p.catch(e => e))).then(()=>{
171186
this._logger.info(`'${this._failures.length}' records failed to import.`);
172187

173188
if (this._failures.length > 0) {
@@ -267,20 +282,6 @@ class ImportCSVDiscussionsAction implements IContributedMenuSource {
267282

268283
this._logger.debug("discussion_comment", discussion_comment);
269284

270-
/* batch_payload.push({
271-
"method": "PATCH",
272-
"uri": `/_apis/wit/workitems/${record.WorkItemId}?api-version=4.1`,
273-
"headers": {
274-
"Content-Type": "application/json-patch+json"
275-
},
276-
"body": [{
277-
"op": "add",
278-
"path": "/fields/System.History",
279-
"value": `${discussion_comment}`
280-
}
281-
]
282-
}); */
283-
284285
this._logger.info(`Adding comment for id '${record.WorkItemId}'`);
285286

286287
let response: Response = await this._fetch(url, {

0 commit comments

Comments
 (0)