(id, data)
| 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) |
nothing calls this directly
no test coverage detected