Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 20, 2012
David Powell Fix indentation dad832f
David Powell Speed up autocomplete lookup
- Don't instantiate the Objects, the info is available in the returned structs
6b246d5
Showing with 29 additions and 28 deletions.
  1. +29 −28 lib/slim_dash.rb
View
57 lib/slim_dash.rb
@@ -10,25 +10,25 @@ def today_entries(user)
:order => [:start_time.asc])
entries.map do |te|
entry = { :id => te.id,
- :start => te.start_time,
- :end => te.in_progress ? nil : te.end_time,
- :duration => te.duration_in_seconds,
- :comments => te.comments,
- :target_hours_per_point => Report::Task::TARGET_HOURS_PER_POINT_ON_FEATURES,
- :synced => te.slimtimer_synced
- }
- if te.slimtimer_task
- entry.merge!({ :synced => te.slimtimer_synced,
- :task_name => te.slimtimer_task.name,
- :task_id => te.slimtimer_task.id,
- :total_time => total_time_for_task(te.slimtimer_task),
- :story_name => te.slimtimer_task.story.try(:name),
- :estimate => te.slimtimer_task.story.try(:estimate)
- })
- else
- entry.merge!({ :task_name => "Error: Slimtimer Task not found"})
+ :start => te.start_time,
+ :end => te.in_progress ? nil : te.end_time,
+ :duration => te.duration_in_seconds,
+ :comments => te.comments,
+ :target_hours_per_point => Report::Task::TARGET_HOURS_PER_POINT_ON_FEATURES,
+ :synced => te.slimtimer_synced
+ }
+ if te.slimtimer_task
+ entry.merge!({ :synced => te.slimtimer_synced,
+ :task_name => te.slimtimer_task.name,
+ :task_id => te.slimtimer_task.id,
+ :total_time => total_time_for_task(te.slimtimer_task),
+ :story_name => te.slimtimer_task.story.try(:name),
+ :estimate => te.slimtimer_task.story.try(:estimate)
+ })
+ else
+ entry.merge!({ :task_name => "Error: Slimtimer Task not found"})
end
- entry
+ entry
end.to_json
end
@@ -140,7 +140,8 @@ def autocomplete(term)
cond = term.split(' ').map {|t| "str LIKE '%#{t}%'"} . join " AND "
task_ids = repository(:default).adapter.select(<<-"SQL"
- SELECT * FROM (SELECT t.id,concat_ws(' ',t.name,s.name,s.description) as str, created, hours
+ SELECT * FROM (SELECT t.id,concat_ws(' ',t.name,s.name,s.description) as str, created, hours,
+ t.name as task_name, s.name as story_name
FROM slimtimer_tasks t LEFT JOIN stories s ON (t.story_id=s.id)
WHERE not completed AND (s.status IS NULL OR s.status <> 'accepted')) x
WHERE TRUE AND #{cond}
@@ -150,18 +151,18 @@ def autocomplete(term)
)
slim_res = task_ids.map do |task_struct|
- task = SlimtimerTask.get(task_struct.id)
- label = task.name
- label += " : #{task.story.name}" if task.story
- { :value => "#{task.id}",
+ label = task_struct.task_name
+ label += " : #{task_struct.story_name}" if task_struct.story_name
+ { :value => "#{task_struct.id}",
:label => label}
end
max_remaining = [0, max_autocomplete - slim_res.length].max
# Now stories *without* a task yet. That is, probably unstarted stories
story_ids = repository(:default).adapter.select(<<-"SQL"
- SELECT * FROM (SELECT s.id,concat_ws(' ',s.name,s.description) as str
+ SELECT * FROM (SELECT s.id,concat_ws(' ',s.name,s.description) as str,
+ s.project_id, s.name
FROM stories s LEFT JOIN slimtimer_tasks t ON (t.story_id=s.id)
WHERE t.id IS NULL AND s.status <> 'accepted') x
WHERE TRUE AND #{cond}
@@ -171,10 +172,10 @@ def autocomplete(term)
)
slim_res += story_ids.map do |story_struct|
- story = Story.get(story_struct.id)
- project_name = story.project ? story.project.name : "UNKNOWN"
- { :value => "STORY:#{story.id}",
- :label => "#{project_name} : #{story.id} #{story.name}"}
+ project = Project.find_by_pivotal_id(story_struct.project_id)
+ project_name = project ? project.name : "UNKNOWN"
+ { :value => "STORY:#{story_struct.id}",
+ :label => "#{project_name} : #{story_struct.id} #{story_struct.name}"}
end
slim_res.to_json

No commit comments for this range

Something went wrong with that request. Please try again.