Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grouping error: grouped by user (time_entry_count_by_group) #71

Open
rNoz opened this issue Apr 1, 2017 · 1 comment
Open

Grouping error: grouped by user (time_entry_count_by_group) #71

rNoz opened this issue Apr 1, 2017 · 1 comment

Comments

@rNoz
Copy link

rNoz commented Apr 1, 2017

My system:

Environment:
  Redmine version                3.3.2.stable
  Ruby version                   2.3.4-p301 (2017-03-30) [x86_64-linux]
  Rails version                  4.2.7.1
  Environment                    development
  Database adapter               PostgreSQL
SCM:
  Git                            2.12.0
  Filesystem                     
Redmine plugins:
  timesheet                      0.7.0

I create a project and a couple of issues asigned to myself.

Then, I go to timesheet, and select group by user, apply filters, and I get this error:

Started GET "/timesheet" for ::1 at 2017-04-01 16:07:48 +0200
Processing by TimesheetsController#show as HTML
  SQL (2.1ms)  UPDATE "tokens" SET "updated_on" = '2017-04-01 16:07:48.947705' WHERE "tokens"."user_id" = $1 AND "tokens"."value" = $2 AND "tokens"."action" = $3  [["user_id", 1], ["value", "21cecb468c751597d5fe259d27efdb0a9b397f9a"], ["action", "session"]]
   (0.3ms)  SELECT MAX("settings"."updated_on") FROM "settings"
  User Load (0.3ms)  SELECT  "users".* FROM "users" WHERE "users"."type" IN ('User', 'AnonymousUser') AND "users"."status" = $1 AND "users"."id" = $2 LIMIT 1  [["status", 1], ["id", 1]]
  Current user: admin (id=1)
  TimeEntryCustomField Load (0.9ms)  SELECT "custom_fields".* FROM "custom_fields" WHERE "custom_fields"."type" IN ('TimeEntryCustomField')
  IssueCustomField Load (0.2ms)  SELECT "custom_fields".* FROM "custom_fields" WHERE "custom_fields"."type" IN ('IssueCustomField') AND "custom_fields"."is_for_all" = $1  [["is_for_all", "t"]]
  Project Load (0.2ms)  SELECT "projects".* FROM "projects" WHERE (projects.status <> 9)
  Principal Load (0.3ms)  SELECT "users".* FROM "users" WHERE "users"."status" = $1 AND (users.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (1)))  [["status", 1]]
  Member Exists (0.2ms)  SELECT  1 AS one FROM "members" INNER JOIN "projects" ON "projects"."id" = "members"."project_id" WHERE "members"."user_id" = $1 AND (projects.status<>9) LIMIT 1  [["user_id", 1]]
   (0.4ms)  SELECT COUNT(*) FROM "enumerations" WHERE "enumerations"."type" IN ('TimeEntryActivity') AND"enumerations"."project_id" IS NULL
  TimeEntryActivity Load (0.9ms)  SELECT "enumerations".* FROM "enumerations" WHERE "enumerations"."type" IN ('TimeEntryActivity') AND "enumerations"."project_id" IS NULL  ORDER BY "enumerations"."position" ASC
  TimeEntryCustomField Load (0.2ms)  SELECT "custom_fields".* FROM "custom_fields" WHERE "custom_fields"."type" IN ('TimeEntryCustomField') AND "custom_fields"."is_filter" = $1  ORDER BY "custom_fields"."position" ASC  [["is_filter", "t"]]
  CustomField Load (0.2ms)  SELECT "custom_fields".* FROM "custom_fields" WHERE "custom_fields"."is_filter" = $1  [["is_filter", "t"]]
  IssueCustomField Load (0.3ms)  SELECT "custom_fields".* FROM "custom_fields" WHERE "custom_fields"."type" IN ('IssueCustomField') AND "custom_fields"."is_for_all" = $1 AND "custom_fields"."is_filter" = $2  ORDER BY "custom_fields"."position" ASC  [["is_for_all", "t"], ["is_filter", "t"]]
  CACHE (0.0ms)  SELECT "custom_fields".* FROM "custom_fields" WHERE "custom_fields"."is_filter" = $1  [["is_filter", true]]
  ActsAsTaggableOn::Tag Load (0.6ms)  SELECT "tags".* FROM "tags" WHERE (id in (select tag_id from taggings where taggable_type = 'Issue'))
   (1.3ms)  SELECT COUNT(DISTINCT "time_entries"."id") FROM "time_entries" INNER JOIN "projects" ON "projects"."id" = "time_entries"."project_id" INNER JOIN "users" ON "users"."id" = "time_entries"."user_id" AND "users"."type" IN ('User', 'AnonymousUser') LEFT OUTER JOIN "enumerations" ON "enumerations"."id" = "time_entries"."activity_id" AND "enumerations"."type" IN ('TimeEntryActivity') LEFT OUTER JOIN "issues" ON "issues"."id" = "time_entries"."issue_id" WHERE (projects.status <> 9 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='time_tracking')) AND ((time_entries.spent_on IS NOT NULL) AND (time_entries.user_id IN ('1')))
  SQL (2.2ms)  SELECT  "time_entries"."id" AS t0_r0, "time_entries"."project_id" AS t0_r1, "time_entries"."user_id" AS t0_r2, "time_entries"."issue_id" AS t0_r3, "time_entries"."hours" AS t0_r4, "time_entries"."comments" AS t0_r5, "time_entries"."activity_id" AS t0_r6, "time_entries"."spent_on" AS t0_r7, "time_entries"."tyear" AS t0_r8, "time_entries"."tmonth" AS t0_r9, "time_entries"."tweek" AS t0_r10, "time_entries"."created_on" AS t0_r11, "time_entries"."updated_on" AS t0_r12, "enumerations"."id" AS t1_r0, "enumerations"."name" AS t1_r1, "enumerations"."position" AS t1_r2, "enumerations"."is_default" AS t1_r3, "enumerations"."type" AS t1_r4, "enumerations"."active" AS t1_r5, "enumerations"."project_id" AS t1_r6, "enumerations"."parent_id" AS t1_r7, "enumerations"."position_name" AS t1_r8, "projects"."id" AS t2_r0, "projects"."name" AS t2_r1, "projects"."description" AS t2_r2, "projects"."homepage" AS t2_r3, "projects"."is_public" AS t2_r4, "projects"."parent_id" AS t2_r5, "projects"."created_on" AS t2_r6, "projects"."updated_on" AS t2_r7, "projects"."identifier" AS t2_r8, "projects"."status" AS t2_r9, "projects"."lft" AS t2_r10, "projects"."rgt" AS t2_r11, "projects"."inherit_members" AS t2_r12, "projects"."default_version_id" AS t2_r13, "users"."id" AS t3_r0, "users"."login" AS t3_r1, "users"."hashed_password" AS t3_r2, "users"."firstname" AS t3_r3, "users"."lastname" AS t3_r4, "users"."admin" AS t3_r5, "users"."status" AS t3_r6, "users"."last_login_on" AS t3_r7, "users"."language" AS t3_r8, "users"."auth_source_id" AS t3_r9, "users"."created_on" AS t3_r10, "users"."updated_on" AS t3_r11, "users"."type" AS t3_r12, "users"."identity_url" AS t3_r13,"users"."mail_notification" AS t3_r14, "users"."salt" AS t3_r15, "users"."must_change_passwd" AS t3_r16,"users"."passwd_changed_on" AS t3_r17, "issues"."id" AS t4_r0, "issues"."tracker_id" AS t4_r1, "issues"."project_id" AS t4_r2, "issues"."subject" AS t4_r3, "issues"."description" AS t4_r4, "issues"."due_date" AS t4_r5, "issues"."category_id" AS t4_r6, "issues"."status_id" AS t4_r7, "issues"."assigned_to_id" AS t4_r8, "issues"."priority_id" AS t4_r9, "issues"."fixed_version_id" AS t4_r10, "issues"."author_id" AS t4_r11, "issues"."lock_version" AS t4_r12, "issues"."created_on" AS t4_r13, "issues"."updated_on" AS t4_r14, "issues"."start_date" AS t4_r15, "issues"."done_ratio" AS t4_r16, "issues"."estimated_hours" AS t4_r17, "issues"."parent_id" AS t4_r18, "issues"."root_id" AS t4_r19, "issues"."lft" AS t4_r20, "issues"."rgt" AS t4_r21, "issues"."is_private" AS t4_r22, "issues"."closed_on" AS t4_r23 FROM "time_entries" INNER JOIN "projects" ON "projects"."id" = "time_entries"."project_id" INNER JOIN "users" ON "users"."id" = "time_entries"."user_id" AND "users"."type" IN ('User', 'AnonymousUser') LEFT OUTER JOIN "enumerations" ON "enumerations"."id" = "time_entries"."activity_id" AND "enumerations"."type" IN ('TimeEntryActivity') LEFT OUTER JOIN "issues" ON "issues"."id" = "time_entries"."issue_id" WHERE (projects.status <> 9 AND projects.id IN(SELECT em.project_id FROM enabled_modules em WHERE em.name='time_tracking')) AND ((time_entries.spent_on IS NOT NULL) AND (time_entries.user_id IN ('1')))  ORDER BY users.firstname ASC, users.lastname ASC, users.id ASC, time_entries.spent_on DESC, time_entries.created_on DESC LIMIT 25 OFFSET 0
   (1.1ms)  SELECT SUM("time_entries"."hours") FROM "time_entries" INNER JOIN "projects" ON "projects"."id" = "time_entries"."project_id" INNER JOIN "users" ON "users"."id" = "time_entries"."user_id" AND "users"."type" IN ('User', 'AnonymousUser') LEFT OUTER JOIN "enumerations" ON "enumerations"."id" = "time_entries"."activity_id" AND "enumerations"."type" IN ('TimeEntryActivity') LEFT OUTER JOIN "issues" ON "issues"."id" = "time_entries"."issue_id" WHERE (projects.status <> 9 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='time_tracking')) AND ((time_entries.spent_on IS NOT NULL) AND (time_entries.user_id IN ('1')))
Deface: 1 overrides found for 'layouts/base'
Deface: 'add-body-header' matched 1 times with 'div#wrapper'
Deface: [ERROR] The original source for 'add-body-header' has changed, this override should be reviewed to ensure it's still valid.
  Rendered queries/_filters.html.erb (2.4ms)
  Rendered plugins/timesheet/app/views/timesheets/_form.html.erb (7.0ms)
   (1.3ms)  SELECT SUM(time_entries.hours) FROM "time_entries" INNER JOIN "projects" ON "projects"."id" = "time_entries"."project_id" INNER JOIN "users" ON "users"."id" = "time_entries"."user_id" AND "users"."type" IN ('User', 'AnonymousUser') LEFT OUTER JOIN "enumerations" ON "enumerations"."id" = "time_entries"."activity_id" AND "enumerations"."type" IN ('TimeEntryActivity') LEFT OUTER JOIN "issues" ON "issues"."id" = "time_entries"."issue_id" WHERE (projects.status <> 9 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='time_tracking')) AND ((time_entries.spent_on IS NOT NULL) AND (time_entries.user_id IN ('1')))
   (0.8ms)  SELECT COUNT(DISTINCT "time_entries"."id") AS count_id, "time_entries"."user_id" AS time_entries_user_id FROM "time_entries" INNER JOIN "projects" ON "projects"."id" = "time_entries"."project_id" INNER JOIN "users" ON "users"."id" = "time_entries"."user_id" AND "users"."type" IN ('User', 'AnonymousUser') LEFT OUTER JOIN "enumerations" ON "enumerations"."id" = "time_entries"."activity_id" AND "enumerations"."type" IN ('TimeEntryActivity') LEFT OUTER JOIN "issues" ON "issues"."id" = "time_entries"."issue_id" WHERE (projects.status <> 9 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='time_tracking')) AND ((time_entries.spent_on IS NOT NULL) AND (time_entries.user_id IN ('1'))) GROUP BY "time_entries"."user_id"  ORDER BY users.firstname ASC, users.lastname ASC, users.id ASC
  Rendered plugins/timesheet/app/views/timesheets/_list.html.erb (6.6ms)
  Rendered plugins/timesheet/app/views/timesheets/show.html.erb within layouts/base (18.8ms)
Completed 500 Internal Server Error in 70ms (ActiveRecord: 13.9ms)

ActionView::Template::Error (PG::GroupingError: ERROR:  column "users.firstname" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: ...1'))) GROUP BY "time_entries"."user_id"  ORDER BY users.firs...
                                                             ^
: SELECT COUNT(DISTINCT "time_entries"."id") AS count_id, "time_entries"."user_id" AS time_entries_user_id FROM "time_entries" INNER JOIN "projects" ON "projects"."id" = "time_entries"."project_id" INNER JOIN "users" ON "users"."id" = "time_entries"."user_id" AND "users"."type" IN ('User', 'AnonymousUser') LEFT OUTER JOIN "enumerations" ON "enumerations"."id" = "time_entries"."activity_id" AND "enumerations"."type" IN ('TimeEntryActivity') LEFT OUTER JOIN "issues" ON "issues"."id" = "time_entries"."issue_id" WHERE (projects.status <> 9 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='time_tracking')) AND ((time_entries.spent_on IS NOT NULL) AND (time_entries.user_id IN ('1'))) GROUP BY "time_entries"."user_id"  ORDER BY users.firstname ASC, users.lastname ASC, users.id ASC):
    13:       <% end %>
    14:     </tr>
    15:   </thead>
    16:   <tbody>
    17:   <% grouped_time_entry_list(time_entries, query, query.time_entry_count_by_group) do |time_entry, group_name, group_count, group_totals| -%>
    18:   <% if group_name %>
    19:     <% reset_cycle %>
  app/models/query.rb:685:in `rescue in grouped_query'
  app/models/query.rb:670:in `grouped_query'
  plugins/timesheet/app/models/timesheet_query.rb:42:in `time_entry_count_by_group'
  plugins/timesheet/app/views/timesheets/_list.html.erb:16:in `block in _073e3997a26828ed57cc580c081b2ee5'
  plugins/timesheet/app/views/timesheets/_list.html.erb:1:in `_073e3997a26828ed57cc580c081b2ee5'
  plugins/timesheet/app/views/timesheets/show.html.erb:13:in `_e0f06da995ab915a43e7260376c23cd6'
  plugins/timesheet/app/controllers/timesheets_controller.rb:32:in `block (2 levels) in show'
  plugins/timesheet/app/controllers/timesheets_controller.rb:25:in `show'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'


  Rendered /home/userA/.rvm/gems/ruby-2.3.4/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (17.0ms)
  Rendered /home/userA/.rvm/gems/ruby-2.3.4/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.6ms)
  Rendered /home/userA/.rvm/gems/ruby-2.3.4/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.9ms)
  Rendered /home/userA/.rvm/gems/ruby-2.3.4/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (31.7ms)

Also, when I get this error It is impossible to select other parameters to avoid using the group by, because it is where it fails. It is like redmine saves my last filter applied and tries to apply it again (failing, of course).

@rNoz
Copy link
Author

rNoz commented Apr 1, 2017

Ah, reading the code at least I found how to "reset" the filter applied previously (it is saved in session).

The main problem still persists.

URL: /timesheet?set_filter=.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant