alexmonteiro / Redmine-Monitoring-Controlling

Redmine Plugin that works with Highcharts to show tasks on project throught Charts.
Other
131 stars 79 forks source link

id or identifier #59

Closed fundenys closed 12 years ago

fundenys commented 12 years ago

hi, i work on redmine 2.0.3 and ruby 1.8.7 When i install this plugin, i had a problem with mc_tools. i made some change because the project have a id=2 and identifier = 100001 in debug with netbean, the var project_identifier=2 but project.find_by_identifier(2) return null So i commented project= and stringsqlprojectsubprojects and i remplaced #{stringsqlprojectsubprojects} by #{project_identifier} and its ok def countTasks(project_identifier, isClosed)

get main project

#project = Project.find_by_identifier(project_identifier)
#get projects and sub projects
#stringSqlProjectsSubProjects = return_ids(project.id)
total = 0
Issue.find_by_sql(["select count(1) as totalclosedissue
                    from issues
                    where project_id in (#{project_identifier})
                    and status_id in (select id from issue_statuses where is_closed = ?)",isClosed]).each do |t|
  total = t.totalclosedissue.to_i
end

total

end its the same when i click on bar graphic. he open a new window with project/1000001/issue? and not redmine/project/2/issue? identifier is not the same as id Can you confirm this and say me how you debug your plugin(i have some probleme with javascript in debug)

alexmonteiro commented 12 years ago

The redmine uses the :identifier find a project. By default the params use thought the url REST action (get or post) is the :id like http://www.yourredmine.com/projects/:id. On controller to get the project u have to use the :id as params from URL to use as :identifier as follow the code: // url .../projects/100001/ @project = Project.find_by_identifier(params[:id])

After that the controllers works with the @project.id to find the subprojects. stringSqlProjectsSubProjects = tool.return_ids(@project.id) @projects_subprojects = Project.find_by_sql("select * from projects where id in (#{stringSqlProjectsSubProjects});")

Actually Im developing using Textmate edit and Firebug (Firefox inspect and debug the javascripts) only.

Hope helped you.

Thanks for reporting.

fundenys commented 12 years ago

ok, i just replaced project = Project.find_by_identifier(project_identifier) by project = Project.find_by_id(project_identifier) and its ok to find stringSqlProjectsSubProjects. i can now use where project_id in (#{stringSqlProjectsSubProjects}) I will now look at what happens at the click. thank you very much for your quick response