Skip to content

Commit

Permalink
Fix vrp query, and render schedule button only on project issue page
Browse files Browse the repository at this point in the history
  • Loading branch information
krashish8 committed Apr 17, 2022
1 parent 39f9929 commit 31705b4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 0 additions & 4 deletions app/controllers/schedule_issues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ def show

private

def find_project_by_project_id
@project = Project.find params[:project_id]
end

def authorize
if User.current.allowed_to?(:manage_members, @project, global: false)
true
Expand Down
2 changes: 2 additions & 0 deletions app/views/issues/index/_schedule_button.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<% if params.has_key?(:project_id) %>
<%= form_tag(project_schedule_issues_path(@project), method: :get) do %>
<p class="buttons">
<%= submit_tag l(:button_schedule_issues), name: nil %>
</p>
<% end %>
<% end %>
16 changes: 8 additions & 8 deletions lib/redmine_gtt_scheduler/vrp_solution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ def call
-- Jobs SQL
$JOBS$
WITH custom_table AS (
SELECT * FROM crosstab(
'SELECT customized_id, name, array_agg(CASE WHEN value = $$$$ THEN NULL ELSE value END)
FROM custom_values CV
JOIN custom_fields F ON CV.custom_field_id=F.id
GROUP BY customized_id, name ORDER BY customized_id, name'
) AS (id INT, skills TEXT[], volume TEXT[], weight TEXT[])
SELECT * FROM crosstab(
'SELECT customized_id, name, array_agg(CASE WHEN value = $$$$ THEN NULL ELSE value END)
FROM custom_values CV
JOIN custom_fields F ON CV.custom_field_id=F.id AND F.name in ($$Skills$$, $$Weight$$, $$Volume$$)
GROUP BY customized_id, name ORDER BY customized_id, name'
) AS (id INT, skills TEXT[], volume TEXT[], weight TEXT[])
)
SELECT
I.id AS id,
Expand Down Expand Up @@ -89,7 +89,7 @@ def call
SELECT * FROM crosstab(
'SELECT customized_id, name, array_agg(CASE WHEN value = $$$$ THEN NULL ELSE value END)
FROM custom_values CV
JOIN custom_fields F ON CV.custom_field_id=F.id
JOIN custom_fields F ON CV.custom_field_id=F.id AND F.name in ($$Skills$$, $$Weight$$, $$Volume$$)
GROUP BY customized_id, name ORDER BY customized_id, name'
) AS (id INT, skills TEXT[], volume TEXT[], weight TEXT[])
)
Expand Down Expand Up @@ -124,7 +124,7 @@ def call
SELECT * FROM crosstab(
'SELECT customized_id, name, array_agg(CASE WHEN value = $$$$ THEN NULL ELSE value END)
FROM custom_values CV
JOIN custom_fields F ON CV.custom_field_id=F.id
JOIN custom_fields F ON CV.custom_field_id=F.id AND F.name in ($$Skills$$, $$Weight$$, $$Volume$$, $$Speed Factor$$, $$Max Tasks$$, $$Vehicle$$)
GROUP BY customized_id, name ORDER BY customized_id, name'
) AS (id INT, max_tasks TEXT[], skills TEXT[], speed_factor TEXT[], vehicle TEXT[], volume TEXT[], weight TEXT[])
)
Expand Down

0 comments on commit 31705b4

Please sign in to comment.