MCPcopy Index your code
hub / github.com/linuxfoundation/crowd.dev / update

Method update

backend/src/services/reportService.ts:97–133  ·  view source on GitHub ↗
(id, data)

Source from the content-addressed store, hash-verified

95 }
96
97 async update(id, data) {
98 const transaction = await SequelizeRepository.createTransaction(this.options)
99
100 try {
101 if (data.widgets) {
102 data.widgets = await WidgetRepository.filterIdsInTenant(data.widgets, {
103 ...this.options,
104 transaction,
105 })
106 }
107
108 const recordBeforeUpdate = await ReportRepository.findById(id, { ...this.options })
109 const record = await ReportRepository.update(id, data, {
110 ...this.options,
111 transaction,
112 })
113
114 if (
115 (data.published === true || data.published === 'true') &&
116 (record.published === true || record.published === 'true') &&
117 recordBeforeUpdate.published !== record.published &&
118 !IS_TEST_ENV
119 ) {
120 track('Report Published', { id: record.id }, { ...this.options })
121 }
122
123 await SequelizeRepository.commitTransaction(transaction)
124
125 return record
126 } catch (error) {
127 await SequelizeRepository.rollbackTransaction(transaction)
128
129 SequelizeRepository.handleUniqueFieldError(error, this.options.language, 'report')
130
131 throw error
132 }
133 }
134
135 async destroyAll(ids) {
136 const transaction = await SequelizeRepository.createTransaction(this.options)

Callers

nothing calls this directly

Calls 7

trackFunction · 0.85
createTransactionMethod · 0.80
commitTransactionMethod · 0.80
rollbackTransactionMethod · 0.80
filterIdsInTenantMethod · 0.45
findByIdMethod · 0.45

Tested by

no test coverage detected