mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-21 01:30:12 +01:00
Remove trailing whitespace and tabs
This commit is contained in:
parent
863d780ad0
commit
aa41e20e46
84 changed files with 407 additions and 407 deletions
|
|
@ -10,7 +10,7 @@ class StatsController < ApplicationController
|
|||
@hidden_contexts = current_user.contexts.hidden
|
||||
@stats = Stats::UserStats.new(current_user)
|
||||
end
|
||||
|
||||
|
||||
def actions_done_last12months_data
|
||||
# get actions created and completed in the past 12+3 months. +3 for running
|
||||
# - outermost set of entries needed for these calculations
|
||||
|
|
@ -19,7 +19,7 @@ class StatsController < ApplicationController
|
|||
# convert to array and fill in non-existing months
|
||||
@actions_done_last12months_array = put_events_into_month_buckets(actions_last12months, 13, :completed_at)
|
||||
@actions_created_last12months_array = put_events_into_month_buckets(actions_last12months, 13, :created_at)
|
||||
|
||||
|
||||
# find max for graph in both arrays
|
||||
@max = (@actions_done_last12months_array + @actions_created_last12months_array).max
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ class StatsController < ApplicationController
|
|||
|
||||
def actions_done_lastyears_data
|
||||
actions_last_months = current_user.todos.select("completed_at,created_at")
|
||||
|
||||
|
||||
month_count = difference_in_months(@today, actions_last_months.minimum(:created_at))
|
||||
# because this action is not scoped by date, the minimum created_at should always be
|
||||
# less than the minimum completed_at, so no reason to check minimum completed_at
|
||||
|
|
@ -101,10 +101,10 @@ class StatsController < ApplicationController
|
|||
# convert to array and fill in non-existing weeks with 0
|
||||
@max_weeks = @actions_completion_time.last ? difference_in_weeks(@today, @actions_completion_time.last.completed_at) : 1
|
||||
@actions_completed_per_week_array = convert_to_weeks_running_array(@actions_completion_time, @max_weeks+1)
|
||||
|
||||
|
||||
# stop the chart after 10 weeks
|
||||
@count = [10, @max_weeks].min
|
||||
|
||||
|
||||
# convert to new array to hold max @cut_off elems + 1 for sum of actions after @cut_off
|
||||
@actions_completion_time_array = cut_off_array_with_sum(@actions_completed_per_week_array, @count)
|
||||
@max_actions = @actions_completion_time_array.max
|
||||
|
|
@ -124,14 +124,14 @@ class StatsController < ApplicationController
|
|||
|
||||
# cut off chart at 52 weeks = one year
|
||||
@count = [52, @max_weeks].min
|
||||
|
||||
|
||||
# convert to new array to hold max @cut_off elems + 1 for sum of actions after @cut_off
|
||||
@actions_running_time_array = cut_off_array_with_sum(@actions_running_per_week_array, @count)
|
||||
@max_actions = @actions_running_time_array.max
|
||||
|
||||
# get percentage done cumulative
|
||||
@cum_percent_done = convert_to_cumulative_array(@actions_running_time_array, @actions_running_time.count )
|
||||
|
||||
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ class StatsController < ApplicationController
|
|||
|
||||
# cut off chart at 52 weeks = one year
|
||||
@count = [52, @max_weeks].min
|
||||
|
||||
|
||||
# convert to new array to hold max @cut_off elems + 1 for sum of actions after @cut_off
|
||||
@actions_running_time_array = cut_off_array_with_sum(@actions_running_per_week_array, @count)
|
||||
@max_actions = @actions_running_time_array.max
|
||||
|
|
@ -163,21 +163,21 @@ class StatsController < ApplicationController
|
|||
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
|
||||
def actions_open_per_week_data
|
||||
@actions_started = current_user.todos.created_after(@today-53.weeks).
|
||||
select("todos.created_at, todos.completed_at").
|
||||
reorder("todos.created_at DESC")
|
||||
|
||||
|
||||
@max_weeks = difference_in_weeks(@today, @actions_started.last.created_at)
|
||||
|
||||
# cut off chart at 52 weeks = one year
|
||||
@count = [52, @max_weeks].min
|
||||
|
||||
|
||||
@actions_open_per_week_array = convert_to_weeks_running_from_today_array(@actions_started, @max_weeks+1)
|
||||
@actions_open_per_week_array = cut_off_array(@actions_open_per_week_array, @count)
|
||||
@max_actions = (@actions_open_per_week_array.max or 0)
|
||||
|
||||
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
|
|
@ -323,7 +323,7 @@ class StatsController < ApplicationController
|
|||
selected_todo_ids = get_ids_from(@actions_running_time, week_from, week_to, params['id']=='art_end')
|
||||
@selected_actions = selected_todo_ids.size == 0 ? [] : current_user.todos.where("id in (#{selected_todo_ids.join(",")})")
|
||||
@count = @selected_actions.size
|
||||
|
||||
|
||||
render :action => "show_selection_from_chart"
|
||||
else
|
||||
# render error
|
||||
|
|
@ -380,7 +380,7 @@ class StatsController < ApplicationController
|
|||
records.each { |r| (yield r).each { |i| a[i] += 1 if a[i] } }
|
||||
a
|
||||
end
|
||||
|
||||
|
||||
def put_events_into_month_buckets(records, array_size, date_method_on_todo)
|
||||
convert_to_array(records.select { |x| x.send(date_method_on_todo) }, array_size) { |r| [difference_in_months(@today, r.send(date_method_on_todo))]}
|
||||
end
|
||||
|
|
@ -400,7 +400,7 @@ class StatsController < ApplicationController
|
|||
def convert_to_weeks_running_from_today_array(records, array_size)
|
||||
return convert_to_array(records, array_size) { |r| week_indexes_of(r) }
|
||||
end
|
||||
|
||||
|
||||
def week_indexes_of(record)
|
||||
a = []
|
||||
start_week = difference_in_weeks(@today, record.created_at)
|
||||
|
|
@ -408,7 +408,7 @@ class StatsController < ApplicationController
|
|||
end_week.upto(start_week) { |i| a << i };
|
||||
return a
|
||||
end
|
||||
|
||||
|
||||
# returns a new array containing all elems of array up to cut_off and
|
||||
# adds the sum of the rest of array to the last elem
|
||||
def cut_off_array_with_sum(array, cut_off)
|
||||
|
|
@ -418,7 +418,7 @@ class StatsController < ApplicationController
|
|||
a[cut_off] += array.inject(:+) - a.inject(:+)
|
||||
return a
|
||||
end
|
||||
|
||||
|
||||
def cut_off_array(array, cut_off)
|
||||
return Array.new(cut_off){|i| array[i]||0}
|
||||
end
|
||||
|
|
@ -441,7 +441,7 @@ class StatsController < ApplicationController
|
|||
def difference_in_days(date1, date2)
|
||||
return ((date1.utc.at_midnight-date2.utc.at_midnight)/SECONDS_PER_DAY).to_i
|
||||
end
|
||||
|
||||
|
||||
# assumes date1 > date2
|
||||
def difference_in_weeks(date1, date2)
|
||||
return difference_in_days(date1, date2) / 7
|
||||
|
|
@ -458,7 +458,7 @@ class StatsController < ApplicationController
|
|||
# sets "null" on first column and - if necessary - cleans up last two columns, which may have insufficient data
|
||||
def compute_running_avg_array(set, upper_bound)
|
||||
result = set_three_month_avg(set, upper_bound)
|
||||
result[upper_bound-1] = result[upper_bound-1] * 3 if upper_bound == set.length
|
||||
result[upper_bound-1] = result[upper_bound-1] * 3 if upper_bound == set.length
|
||||
result[upper_bound-2] = result[upper_bound-2] * 3 / 2 if upper_bound > 1 and upper_bound == set.length
|
||||
result[0] = "null"
|
||||
result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue