@@ -11,7 +11,7 @@ import {
11
11
type Session ,
12
12
viewOfChangeset ,
13
13
} from '~/common' ;
14
- import { HandleIdLookup , ILogger , Logger , ResourceResolver } from '~/core' ;
14
+ import { HandleIdLookup , ResourceResolver } from '~/core' ;
15
15
import { mapListResults } from '~/core/database/results' ;
16
16
import { Privileges } from '../authorization' ;
17
17
import { FileService } from '../file' ;
@@ -41,15 +41,12 @@ export class BudgetService {
41
41
private readonly budgetRepo : BudgetRepository ,
42
42
private readonly budgetRecordsRepo : BudgetRecordRepository ,
43
43
private readonly resources : ResourceResolver ,
44
- @Logger ( 'budget:service' ) private readonly logger : ILogger ,
45
44
) { }
46
45
47
46
async create (
48
47
{ projectId, ...input } : CreateBudget ,
49
48
session : Session ,
50
49
) : Promise < Budget > {
51
- this . logger . debug ( 'Creating budget' , { projectId } ) ;
52
-
53
50
const universalTemplateFileId = await generateId < FileId > ( ) ;
54
51
55
52
try {
@@ -58,11 +55,6 @@ export class BudgetService {
58
55
universalTemplateFileId ,
59
56
) ;
60
57
61
- this . logger . debug ( `Created Budget` , {
62
- id : budgetId ,
63
- userId : session . userId ,
64
- } ) ;
65
-
66
58
await this . files . createDefinedFile (
67
59
universalTemplateFileId ,
68
60
`Universal Budget Template` ,
@@ -75,10 +67,6 @@ export class BudgetService {
75
67
76
68
return await this . readOne ( budgetId , session ) ;
77
69
} catch ( exception ) {
78
- this . logger . error ( `Could not create budget` , {
79
- userId : session . userId ,
80
- exception,
81
- } ) ;
82
70
throw new CreationFailed ( Budget , { cause : exception } ) ;
83
71
}
84
72
}
@@ -98,16 +86,9 @@ export class BudgetService {
98
86
99
87
await this . verifyRecordUniqueness ( input ) ;
100
88
101
- this . logger . debug ( 'Creating BudgetRecord' , input ) ;
102
-
103
89
try {
104
90
const recordId = await this . budgetRecordsRepo . create ( input , changeset ) ;
105
91
106
- this . logger . debug ( `Created Budget Record` , {
107
- id : recordId ,
108
- userId : session . userId ,
109
- } ) ;
110
-
111
92
const budgetRecord = await this . readOneRecord (
112
93
recordId ,
113
94
session ,
@@ -116,10 +97,6 @@ export class BudgetService {
116
97
117
98
return budgetRecord ;
118
99
} catch ( exception ) {
119
- this . logger . error ( `Could not create Budget Record` , {
120
- userId : session . userId ,
121
- exception,
122
- } ) ;
123
100
throw new CreationFailed ( BudgetRecord , { cause : exception } ) ;
124
101
}
125
102
}
@@ -136,11 +113,6 @@ export class BudgetService {
136
113
137
114
@HandleIdLookup ( Budget )
138
115
async readOne ( id : ID , session : Session , view ?: ObjectView ) : Promise < Budget > {
139
- this . logger . debug ( `readOne budget` , {
140
- id,
141
- userId : session . userId ,
142
- } ) ;
143
-
144
116
const result = await this . budgetRepo . readOne ( id , session , view ) ;
145
117
146
118
const privs = this . privileges . for ( Budget , result ) ;
@@ -190,11 +162,6 @@ export class BudgetService {
190
162
session : Session ,
191
163
view ?: ObjectView ,
192
164
) : Promise < BudgetRecord > {
193
- this . logger . debug ( `readOne BudgetRecord` , {
194
- id,
195
- userId : session . userId ,
196
- } ) ;
197
-
198
165
const result = await this . budgetRecordsRepo . readOne ( id , { session, view } ) ;
199
166
200
167
return this . privileges . for ( BudgetRecord ) . secure ( result ) ;
@@ -220,8 +187,6 @@ export class BudgetService {
220
187
session : Session ,
221
188
changeset ?: ID ,
222
189
) : Promise < BudgetRecord > {
223
- this . logger . debug ( 'Update budget record' , { id, userId : session . userId } ) ;
224
-
225
190
const br = await this . readOneRecord (
226
191
id ,
227
192
session ,
@@ -230,20 +195,8 @@ export class BudgetService {
230
195
const changes = this . budgetRecordsRepo . getActualChanges ( br , input ) ;
231
196
this . privileges . for ( BudgetRecord , br ) . verifyChanges ( changes ) ;
232
197
233
- try {
234
- const result = await this . budgetRecordsRepo . update (
235
- br ,
236
- changes ,
237
- changeset ,
238
- ) ;
239
- return result ;
240
- } catch ( e ) {
241
- this . logger . error ( 'Could not update budget Record ' , {
242
- id,
243
- userId : session . userId ,
244
- } ) ;
245
- throw e ;
246
- }
198
+ const result = await this . budgetRecordsRepo . update ( br , changes , changeset ) ;
199
+ return result ;
247
200
}
248
201
249
202
async delete ( id : ID , session : Session ) : Promise < void > {
@@ -257,21 +210,15 @@ export class BudgetService {
257
210
try {
258
211
await this . budgetRepo . deleteNode ( budget ) ;
259
212
} catch ( e ) {
260
- this . logger . warning ( 'Failed to delete budget' , {
261
- exception : e ,
262
- } ) ;
263
- throw new ServerException ( 'Failed to delete budget' ) ;
213
+ throw new ServerException ( 'Failed to delete budget' , e ) ;
264
214
}
265
215
}
266
216
267
217
async deleteRecord ( id : ID , session : Session , changeset ?: ID ) : Promise < void > {
268
218
try {
269
219
await this . budgetRecordsRepo . deleteNode ( id , { changeset } ) ;
270
220
} catch ( e ) {
271
- this . logger . warning ( 'Failed to delete Budget Record' , {
272
- exception : e ,
273
- } ) ;
274
- throw new ServerException ( 'Failed to delete Budget Record' ) ;
221
+ throw new ServerException ( 'Failed to delete Budget Record' , e ) ;
275
222
}
276
223
}
277
224
0 commit comments