Project

General

Profile

Plugin: Weekly Timesheet is not working with postgres

Added by Rachid B almost 13 years ago

Hi,

the new Plugin "weekly Timesheet" does not work with postgres.
It is using mysql-specific funktions: weekday() and addday()
For example this sql-statement needs to be written as:

#mysql
select adddate(t.spent_on,weekday(t.spent_on)*-1) from time_entries t;

#postres
select t.spent_on-cast(extract(dow from t.spent_on) as integer) form time_entries t;


I am not sure, how date-function should used in redmine?

best regards,
rachid


Replies (5)

RE: Plugin: Weekly Timesheet is not working with postgres - Added by Dhanasingh Krishnapandian almost 13 years ago

I was hoping all the sqls would work fine with other DBs as well. Let me take a look

RE: Plugin: Weekly Timesheet is not working with postgres - Added by Dhanasingh Krishnapandian almost 13 years ago

I have added an If statement and added your suggested change (please see below).
This is in version 0.0.3, it should work fine now, please take a look.

  1. postgre doesn't have the weekday function
    if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
    sqlStr = "select user_id, monday as spent_on, hours from " +
    " (select t.spent_on - cast(extract(dow from t.spent_on) as integer) + 1 as monday, "
    end

RE: Plugin: Weekly Timesheet is not working with postgres - Added by Eivind Tagseth almost 13 years ago

This is also a problem when using SQLite, the function adddate does not exist. I added the following in wktime_controller.rb to make it work:

if ActiveRecord::Base.connection.adapter_name == 'SQLite'
sqlStr = "select user_id, monday as spent_on, hours from " +
" (select date(t.spent_on, (select '-' || strftime('%w', t.spent_on, '-1 days') || ' days')) as monday, "
end

Seems to do the trick.

RE: Plugin: Weekly Timesheet is not working with postgres - Added by Dhanasingh Krishnapandian almost 13 years ago

Thanks for the feedback, I have incorporated your suggestion into the code, it is part of release 0.0.4
this is what I have added

elsif ActiveRecord::Base.connection.adapter_name == 'SQLite'
sqlStr = "select user_id, monday as spent_on, hours from " +
" (select date(spent_on, '-' || strftime('%w', spent_on, '-1 days') || ' days') as monday, "
end

RE: Plugin: Weekly Timesheet is not working with postgres - Added by Francisco Almeida almost 13 years ago

How can we give feedback about this plugin?

I open a new forum topic: http://www.redmine.org/boards/3/topics/28282 but I don't know if it's the best way.

Sorry for this post.

Thanks,
Francisco

    (1-5/5)