Skip to content

Commit 38c0f3d

Browse files
committed
fix(docworker): Fix enriching document context
1 parent f879543 commit 38c0f3d

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

packages/dsw-database/dsw/database/database.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ class Database:
4040
'WHERE project_uuid = %s AND tenant_uuid = %s;')
4141
SELECT_DOCUMENT_SUBMISSIONS = ('SELECT * FROM submission '
4242
'WHERE document_uuid = %s AND tenant_uuid = %s;')
43-
SELECT_SUBMISSIONS = ('SELECT s.* '
44-
'FROM document d JOIN submission s ON d.uuid = s.document_uuid '
45-
'WHERE d.project_uuid = %s AND d.tenant_uuid = %s;')
43+
SELECT_PROJECT_SUBMISSIONS = ('SELECT s.* '
44+
'FROM document d JOIN submission s ON d.uuid = s.document_uuid '
45+
'WHERE d.project_uuid = %s AND d.tenant_uuid = %s;')
4646
SELECT_PROJECT_SIMPLE = ('SELECT p.* FROM project p '
4747
'WHERE p.uuid = %s AND p.tenant_uuid = %s;')
4848
SELECT_TENANT_LIMIT = ('SELECT uuid, storage FROM tenant_limit_bundle '
@@ -303,10 +303,10 @@ def fetch_document_submissions(self, document_uuid: str,
303303
after=tenacity.after_log(LOG, logging.DEBUG),
304304
)
305305
def fetch_project_submissions(self, project_uuid: str,
306-
tenant_uuid: str) -> list[DBSubmission]:
306+
tenant_uuid: str) -> list[DBSubmission]:
307307
with self.conn_query.new_cursor(use_dict=True) as cursor:
308308
cursor.execute(
309-
query=self.SELECT_SUBMISSIONS,
309+
query=self.SELECT_PROJECT_SUBMISSIONS,
310310
params=(project_uuid, tenant_uuid),
311311
)
312312
return [DBSubmission.from_dict_row(x) for x in cursor.fetchall()]

packages/dsw-document-worker/dsw/document_worker/worker.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def handled_step(job, *args, **kwargs):
3535
try:
3636
return func(job, *args, **kwargs)
3737
except Exception as e:
38-
LOG.debug('Handling exception', exc_info=True)
38+
LOG.info('Handling exception', exc_info=True)
3939
new_exception = create_job_exception(
4040
job_id=job.doc_uuid,
4141
message=message,
@@ -159,9 +159,9 @@ def _enrich_context_config(self):
159159
self.ctx.app.cfg.context.default_primary_color)
160160
illustrations_color = (old.get('illustrationsColor', None) or
161161
self.ctx.app.cfg.context.default_illustrations_color)
162-
logo_url = (old.get('logoUrl', None) or
163-
self.ctx.app.cfg.context.default_logo_url)
164-
logo_url.replace('{{clientUrl}}', client_url)
162+
logo_url_template = (old.get('logoUrl', None) or
163+
self.ctx.app.cfg.context.default_logo_url)
164+
logo_url = logo_url_template.replace('{{clientUrl}}', client_url)
165165

166166
self.doc_context['config'].update({
167167
'serviceName': self.ctx.app.cfg.context.service_name,
@@ -187,11 +187,18 @@ def _enrich_context(self):
187187
)
188188
extras['submissions'] = [s.to_dict() for s in submissions]
189189
if self.safe_format.requires_via_extras('questionnaire'):
190+
# older deprecated variant (questionnaire -> project)
190191
questionnaire = self.ctx.app.db.fetch_project_simple(
191192
project_uuid=self.safe_doc.project_uuid,
192193
tenant_uuid=self.tenant_uuid,
193194
)
194195
extras['questionnaire'] = questionnaire.to_dict()
196+
if self.safe_format.requires_via_extras('project'):
197+
project = self.ctx.app.db.fetch_project_simple(
198+
project_uuid=self.safe_doc.project_uuid,
199+
tenant_uuid=self.tenant_uuid,
200+
)
201+
extras['project'] = project.to_dict()
195202
self.doc_context['extras'] = extras
196203
self._enrich_context_config()
197204

0 commit comments

Comments
 (0)