fathomssen / redtimer

RedTimer - Redmine Time Tracker
GNU Lesser General Public License v3.0
65 stars 17 forks source link

Could not save the time entry #112

Open rabmine opened 6 years ago

rabmine commented 6 years ago

Hi

Your Redtimer is great! Thank you

I used Redmine 3.4.2 and I noticed that I can create issues via redtimer etc, but cannot save the time entry.

Environment: _Redmine version 3.4.2.stable.16947 Ruby version 2.4.1-p111 (2017-03-22) [x8664-linux] Rails version 4.2.8 Environment production Database adapter Mysql2 SCM: Subversion 1.9.3 Git 2.7.4 Filesystem
Redmine plugins: _redmine_edit_custom_fields 0.0.5 redmine_sharedapi 0.0.2

couldntsavethetimeentry api

production.log _Started POST "/time_entries.json" for 112.202.31.151 at 2017-08-20 18:51:45 +0800 Processing by TimelogController#create as JSON Parameters: {"time_entry"=>{"activity_id"=>9, "custom_fields"=>[{"id"=>8, "value"=>"2017-08-20T10:51:43"}, {"id"=>9, "value"=>"2017-08-20T10:51:43"}], "hours"=>0.3952777777777778, "issue_id"=>2}} Current user: john (id=6) Rendered common/errormessages.api.rsb (0.6ms) Completed 422 Unprocessable Entity in 90ms (Views: 4.1ms | ActiveRecord: 4.3ms)

fathomssen commented 6 years ago

Hi Randy

Thanks for your bug report. Could you please answer the following questions and perform the suggested steps?

  1. Have you installed any other Redmine plugins?
  2. Does creating time entries with begin and end time in the format 2017-08-20T10:51:43 work from Redmine?
  3. Could you please try to disable the begin and end time custom fields in RedTimer?

Best regards Frederick Thomssen

rabmine commented 6 years ago

Thanks for your prompt response.

  1. Just the two, redmine_edit_custom_fields and redmine_shared_api
  2. Yes
  3. After disabling custom fields, still could not save the time entry.

_Started POST "/time_entries.json" for 112.202.31.151 at 2017-08-20 19:55:00 +0800 Processing by TimelogController#create as JSON Parameters: {"time_entry"=>{"activity_id"=>9, "hours"=>1.3730555555555555, "issue_id"=>2}} Current user: john (id=6) Rendered common/errormessages.api.rsb (0.1ms) Completed 422 Unprocessable Entity in 14ms (Views: 0.5ms | ActiveRecord: 2.6ms)

Kind Regards, Randy

fathomssen commented 6 years ago

Did you use the same time logging activity in Redmine and RedTimer? Incidentally, RedTimer shows all available activities within Redmine, not only those permitted for the current project.

rabmine commented 6 years ago

Hi

Yes, the same time logging activity.

My local machine and the Redmine server (as well as the user account) are in the same timezone. RedTimer shows all available activities, everything is working in Redtimer except in saving the time entry to Redmine.

Thank you!

fastclicker commented 6 years ago

I have some futher explanation to it, since I have the same issue.

I have a custom field "activity description" in spent time section which is mandatory. Because I want always a description of our spent time item to be saved, because at the latest when we have to explain gathered times we need a short description why time was logged. So we added a custom field with a text.

In "RedTimer" it seems that this particular field/ more likely every required custom field with out a default, causes the program to prevent time entry from saving. I also haven't found an option to configure a default value or a way to fill the field in UI.

In Detail

I traced the RedTimers POST which is:

{ "time_entry": { "activity_id": 10, "hours": 10, "issue_id": 1424 }}

Response is 422: {"errors":["activity description cannot be blank"]}

-> custom field activity description is missing in POST

I tried to simulate it with curl I could reproduce behavior (same as RedTimer does):

curl -i -X POST http://127.0.0.1/time_entries.json? -H 'X-Redmine-API-Key: XYZ -H 'Content-Type: application/json' ' -d '{ "time_entry": { "activity_id": 10, "hours": 10, "issue_id": 1424 }}'

and solve it with 3 things in curl or redmine:

1) untick Required in custom fields (not good / unwanted) 2) use a default in custom fields ( better but still unwanted) 3) add custom fields to request

curl -i -X POST http://127.0.0.1/time_entries.json? -H 'X-Redmine-API-Key: XYZ -H 'Content-Type: application/json' -d '{ "time_entry": { "activity_id": 10, "hours": 10, "issue_id": 1424, "custom_fields":[{"id":9,"name":"customer"},{"id":7,"name":"activity description","value":"xxxx"}] }}'

Possible conclusion (when my assumptions are correct ;) ) It would be fine to configure it somehow. Maybe even with a config-file where I can put defaults (not that good):

e.g. "custom_fields":[{"id":9,"name":"customer","fill-later"},{"id":7,"name":"activity description","value":"fix"}]

Or probably with a some additional fields in RedTimer

e.g. "custom_fields":[{"id":9,"name":"customer","value":"%extratext2%"},{"id":7,"name":"activity description","value":"%extratext1%"}]

I think at least the feedback of the error message from 422:

{"errors":["activity description cannot be blank"]} and not that cryptic "Could not save the time entry" alone would be helpful or an improvment since it give the user a hint what could have happened

fathomssen commented 6 years ago

Thank you very much for the analysis!

The qtredmine library already supports custom fields for time entries (https://github.com/fathomssen/qtredmine/blob/11765ed083467e02196dd356aa6441cbe223361a/SimpleRedmineClient.cpp#L349-L362). This feature is still missing in RedTimer, though.

These custom fields could go under the comment field (see #24). If they are mandatory, they should always be displayed. If they are optional, they should be able to hide. What do you think?

@randybalugo Is this also the case for you?

Best regards Frederick Thomssen

fastclicker commented 6 years ago

These custom fields could go under the comment field (see #24). If they are mandatory, they should always be displayed.

I think it is very good way to do it.

fastclicker commented 6 years ago

no really related to the bug. But I try to fix #112 / #24 and add custom fields. But I have problems with a build with Ubuntu 16.04/ Qt 5.5.1 / GCC 5.4. I use the specified libs (qt5.5+, GCC 4.8.4+)

qmake -qt5 -r make

shows: MainWindow.cpp: In member function ‘void redtimer::MainWindow::initTrayIcon()’: MainWindow.cpp:487:73: error: no matching function for call to ‘QMenu::addAction(QIcon, QString, redtimer::MainWindow::initTrayIcon()::<lambda()>)’ [this](){display(); settings_->display();} ); ^ In file included from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QMenu:1:0, from MainWindow.cpp:14: ..

none of the QMenu::addAction in qmenu.h matches

fathomssen commented 6 years ago

Hi @fastclicker,

whoops - seems that I used a Qt 5.6 method there. Could you please use a current Qt version from https://launchpad.net/~beineri?

Best regards Frederick Thomssen

fastclicker commented 6 years ago

It worked like a charm with Qt 5.9.1:

Plain install of ubuntu 16.04 apt-get install git sudo apt-get install build-essential

wget http://download.qt.io/official_releases/qt/5.9/5.9.1/qt-opensource-linux-x64-5.9.1.run

chmod +x qt-opensource-linux-x64-5.9.1.run ./qt-opensource-linux-x64-5.9.1.run

sudo apt-get install mesa-common-dev apt-get install libgl1-mesa-dev

-- git clone https://github.com/fathomssen/redtimer.git cd redtimer git submodule update --init /opt/Qt5.9.1/5.9.1/gcc_64/bin/qmake -r make

I hope I haven't missed a step