Log whether download happened
authorKarl O. Pinc <kop@karlpinc.com>
Wed, 2 Oct 2024 19:20:12 +0000 (14:20 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Wed, 2 Oct 2024 19:20:12 +0000 (14:20 -0500)
src/pgwui_sql/views/sql.py

index 648a96e97010d821b6bad6f47f0dbf1cb773b405..f24746c9af937cc116536a7e858d6196c64c982e 100644 (file)
@@ -376,21 +376,23 @@ class SQLResultsHandler(pgwui_core.core.SessionDBHandler):
         return pgwui_core.core.DataLineProcessor(ue, self)
 
 
-def log_response(response):
+def log_response(response, download=False):
     if response['report_success']:
         if pgwui_core.utils.is_checked(response['csv_checked']):
             download_fmt = 'CSV'
         else:
             download_fmt = 'TAB'
-        if pgwui_core.utils.is_checked(response['one_file_checked']):
-            download_as = 'one file'
+        if not download:
+            download_as = 'Displayed on-screen'
+        elif pgwui_core.utils.is_checked(response['one_file_checked']):
+            download_as = 'Download as one file'
         else:
-            download_as = 'a zip file of one file per result set'
+            download_as = 'Download as a zip file of one file per result set'
         log.info(': '.join(
             [f'Successful sql: DB {response["db"]}',
              # ' File ({filename}):'
              f'Download Format {download_fmt}',
-             f'Download as {download_as}',
+             download_as,
              f'By user {response["user"]}']))
 
 
@@ -434,7 +436,7 @@ def sql_view(request):
 
         pmd_response.app_iter = codecs.iterencode(uh.tfile, 'utf_8')
 
-        log_response(response)
+        log_response(response, uh.uf['download'])
         return pmd_response
     else:
         settings = request.registry.settings