@@ -96,27 +96,53 @@ def results_to_file(results, projectId):
9696
9797 w = csv .writer (results_file , delimiter = "\t " , quotechar = "'" )
9898
99- logger .info (
100- f"Got %s groups for project { projectId } to transfer" % len (results .items ())
101- )
99+ logger .info (f"Got { len (results .items ())} groups for project { projectId } " )
102100 for groupId , users in results .items ():
103101 for userId , results in users .items ():
104102
105103 # check if all attributes are set,
106104 # if not don't transfer the results for this group
107105 try :
108106 start_time = results ["startTime" ]
107+ except KeyError as e :
108+ sentry .capture_exception (e )
109+ sentry .capture_message (
110+ "missing attribute 'startTime' for: "
111+ f"{ projectId } /{ groupId } /{ userId } , will skip this one"
112+ )
113+ logger .exception (e )
114+ logger .warning (
115+ "missing attribute 'startTime' for: "
116+ f"{ projectId } /{ groupId } /{ userId } , will skip this one"
117+ )
118+ continue
119+
120+ try :
109121 end_time = results ["endTime" ]
122+ except KeyError as e :
123+ sentry .capture_exception (e )
124+ sentry .capture_message (
125+ "missing attribute 'endTime' for: "
126+ f"{ projectId } /{ groupId } /{ userId } , will skip this one"
127+ )
128+ logger .exception (e )
129+ logger .warning (
130+ "missing attribute 'endTime' for: "
131+ f"{ projectId } /{ groupId } /{ userId } , will skip this one"
132+ )
133+ continue
134+
135+ try :
110136 results = results ["results" ]
111137 except KeyError as e :
112138 sentry .capture_exception (e )
113139 sentry .capture_message (
114- f"at least one missing attribute for: "
140+ " missing attribute 'results' for: "
115141 f"{ projectId } /{ groupId } /{ userId } , will skip this one"
116142 )
117143 logger .exception (e )
118144 logger .warning (
119- f"at least one missing attribute for: "
145+ " missing attribute 'results' for: "
120146 f"{ projectId } /{ groupId } /{ userId } , will skip this one"
121147 )
122148 continue
@@ -170,7 +196,8 @@ def results_to_file(results, projectId):
170196
171197def save_results_to_postgres (results_file ):
172198 """
173- Saves results to a temporary table in postgres using the COPY Statement of Postgres
199+ Saves results to a temporary table in postgres
200+ using the COPY Statement of Postgres
174201 for a more efficient import into the database.
175202
176203 Parameters
0 commit comments