freescout-help-desk / freescout

FreeScout — Free self-hosted help desk & shared mailbox (Zendesk / Help Scout alternative)
https://freescout.net
GNU Affero General Public License v3.0
3.05k stars 501 forks source link

Error when exporting reports #4167

Closed azamat028 closed 3 months ago

azamat028 commented 3 months ago

Hi, I get an error when downloading reports from the check mark in the Sat. Ratings SQLSTATE[42712]: Duplicate alias: 7 ERROR: table name "threads" specified more than once (SQL: select "conversations"."id", "conversations"."number", "conversations"."type", "conversations"."user_id", "conversations"."status", "conversations"."state", "conversations"."mailbox_id", "conversations"."customer_id" as "customer_name", "conversations"."customer_email", "conversations"."threads_count", "conversations"."subject", "conversations"."cc", "conversations"."bcc", "conversations"."has_attachments", "conversations"."channel", "conversations"."created_at", "conversations"."last_reply_at", "conversations"."last_reply_from", "conversations"."closed_at", "conversations"."closed_by_user_id", "customers"."first_name" as "customer_first_name", "customers"."last_name" as "customer_last_name", string_agg(threads.rating, ', ') as sat_ratings from "conversations" left join "customers" on "customers"."id" = "conversations"."customer_id" inner join "threads" on "conversations"."id" = "threads"."conversation_id" inner join "threads" on "conversations"."id" = "threads"."conversation_id" where "conversations"."mailbox_id" in (3, 2, 1) and "conversations"."status" in (1, 2, 3) and "conversations"."state" = 2 and "conversations"."created_at" >= 2024-07-30 00:00:00 and "conversations"."created_at" <= 2024-08-06 23:59:59 group by "conversations"."id", "conversations"."id", "conversations"."number", "conversations"."type", "conversations"."user_id", "conversations"."status", "conversations"."state", "conversations"."mailbox_id", "conversations"."customer_id", "conversations"."customer_email", "conversations"."threads_count", "conversations"."subject", "conversations"."cc", "conversations"."bcc", "conversations"."has_attachments", "conversations"."channel", "conversations"."created_at", "conversations"."last_reply_at", "conversations"."last_reply_from", "conversations"."closed_at", "conversations"."closed_by_user_id", "customers"."first_name", "customers"."last_name" order by "last_reply_at" desc) {"userId":17,"email":"smana@kacd.kz","exception":"[object] (Illuminate\Database\QueryException(code: 42712): SQLSTATE[42712]: Duplicate alias: 7 ERROR: table name \"threads\" specified more than once (SQL: select \"conversations\".\"id\", \"conversations\".\"number\", \"conversations\".\"type\", \"conversations\".\"user_id\", \"conversations\".\"status\", \"conversations\".\"state\", \"conversations\".\"mailbox_id\", \"conversations\".\"customer_id\" as \"customer_name\", \"conversations\".\"customer_email\", \"conversations\".\"threads_count\", \"conversations\".\"subject\", \"conversations\".\"cc\", \"conversations\".\"bcc\", \"conversations\".\"has_attachments\", \"conversations\".\"channel\", \"conversations\".\"created_at\", \"conversations\".\"last_reply_at\", \"conversations\".\"last_reply_from\", \"conversations\".\"closed_at\", \"conversations\".\"closed_by_user_id\", \"customers\".\"first_name\" as \"customer_first_name\", \"customers\".\"last_name\" as \"customer_last_name\", string_agg(threads.rating, ', ') as sat_ratings from \"conversations\" left join \"customers\" on \"customers\".\"id\" = \"conversations\".\"customer_id\" inner join \"threads\" on \"conversations\".\"id\" = \"threads\".\"conversation_id\" inner join \"threads\" on \"conversations\".\"id\" = \"threads\".\"conversation_id\" where \"conversations\".\"mailbox_id\" in (3, 2, 1) and \"conversations\".\"status\" in (1, 2, 3) and \"conversations\".\"state\" = 2 and \"conversations\".\"created_at\" >= 2024-07-30 00:00:00 and \"conversations\".\"created_at\" <= 2024-08-06 23:59:59 group by \"conversations\".\"id\", \"conversations\".\"id\", \"conversations\".\"number\", \"conversations\".\"type\", \"conversations\".\"user_id\", \"conversations\".\"status\", \"conversations\".\"state\", \"conversations\".\"mailbox_id\", \"conversations\".\"customer_id\", \"conversations\".\"customer_email\", \"conversations\".\"threads_count\", \"conversations\".\"subject\", \"conversations\".\"cc\", \"conversations\".\"bcc\", \"conversations\".\"has_attachments\", \"conversations\".\"channel\", \"conversations\".\"created_at\", \"conversations\".\"last_reply_at\", \"conversations\".\"last_reply_from\", \"conversations\".\"closed_at\", \"conversations\".\"closed_by_user_id\", \"customers\".\"first_name\", \"customers\".\"last_name\" order by \"last_reply_at\" desc) at /opt/helpdesk/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, Doctrine\DBAL\Driver\PDO\Exception(code: 42712): SQLSTATE[42712]: Duplicate alias: 7 ERROR: table name \"threads\" specified more than once at /opt/helpdesk/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18, PDOException(code: 42712): SQLSTATE[42712]: Duplicate alias: 7 ERROR: table name \"threads\" specified more than once at /opt/helpdesk/overrides/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:115)

PHP version: PHP 8.1.2-1ubuntu2.15 FreeScout version: 1.8.147 Database: Pgsql (13.8 (Ubuntu 13.8-1.pgdg20.04+1)) Are you using CloudFlare: No Are you using non-official modules: No Web-server: nginx/1.18.0 Export Conversations: 1.0.10 Reports: 1.0.42 image

freescout-help commented 3 months ago

Fixed in latest versions of the following modules: Export Conversations, CRM, Wallboards.