@@ -110,24 +110,6 @@ def create_sql_date_range_filter(date_range: dict) -> str:
110
110
else :
111
111
return ''
112
112
113
- def find (
114
- self ,
115
- id : str ,
116
- event_context : EventContext ,
117
- peeker : Callable = None ,
118
- visible_only = True ,
119
- mapper : Callable = None ,
120
- ):
121
- time_entry = CosmosDBRepository .find (
122
- self , id , event_context , peeker , visible_only , mapper ,
123
- )
124
-
125
- project_dao = projects_model .create_dao ()
126
- project = project_dao .get (time_entry .project_id )
127
- setattr (time_entry , 'project_name' , project .name )
128
-
129
- return time_entry
130
-
131
113
def find_all (
132
114
self ,
133
115
event_context : EventContext ,
@@ -141,19 +123,14 @@ def find_all(
141
123
142
124
custom_params = self .generate_params (date_range )
143
125
144
- time_entries = CosmosDBRepository .find_all (
126
+ return CosmosDBRepository .find_all (
145
127
self ,
146
128
event_context = event_context ,
147
129
conditions = conditions ,
148
130
custom_sql_conditions = custom_sql_conditions ,
149
131
custom_params = custom_params ,
150
132
)
151
133
152
- project_dao = projects_model .create_dao ()
153
- projects = project_dao .get_all ()
154
- add_project_name_to_time_entries (time_entries , projects )
155
- return time_entries
156
-
157
134
def on_create (self , new_item_data : dict , event_context : EventContext ):
158
135
CosmosDBRepository .on_create (self , new_item_data , event_context )
159
136
@@ -310,16 +287,26 @@ def get_all(self, conditions: dict = {}) -> list:
310
287
conditions .update ({"owner_id" : event_ctx .user_id })
311
288
312
289
date_range = self .handle_date_filter_args (args = conditions )
313
- return self .repository .find_all (
290
+ time_entries = self .repository .find_all (
314
291
event_ctx , conditions = conditions , date_range = date_range
315
292
)
316
293
294
+ project_dao = projects_model .create_dao ()
295
+ projects = project_dao .get_all ()
296
+ add_project_name_to_time_entries (time_entries , projects )
297
+ return time_entries
298
+
317
299
def get (self , id ):
318
300
event_ctx = self .create_event_context ("read" )
319
- return self .repository .find (
301
+ time_entry = self .repository .find (
320
302
id , event_ctx , peeker = self .check_whether_current_user_owns_item
321
303
)
322
304
305
+ project_dao = projects_model .create_dao ()
306
+ project = project_dao .get (time_entry .project_id )
307
+ setattr (time_entry , 'project_name' , project .name )
308
+ return time_entry
309
+
323
310
def create (self , data : dict ):
324
311
event_ctx = self .create_event_context ("create" )
325
312
data ['owner_id' ] = event_ctx .user_id
0 commit comments