mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-01 14:58:50 +01:00
More code style fixes
This commit is contained in:
parent
465419f46a
commit
d4c9041ccd
61 changed files with 406 additions and 422 deletions
|
|
@ -5,8 +5,7 @@ class DataController < ApplicationController
|
|||
@page_title = "TRACKS::Export"
|
||||
end
|
||||
|
||||
def import
|
||||
end
|
||||
def import; end
|
||||
|
||||
def csv_map
|
||||
if params[:file].blank?
|
||||
|
|
@ -16,17 +15,17 @@ class DataController < ApplicationController
|
|||
@import_to = params[:import_to]
|
||||
|
||||
begin
|
||||
#get column headers and format as [['name', column_number]...]
|
||||
# Get column headers and format as [['name', column_number]...]
|
||||
i = -1
|
||||
@headers = import_headers(params[:file].path).collect { |v| [v, i+=1] }
|
||||
@headers.unshift ['',i]
|
||||
@headers = import_headers(params[:file].path).collect { |v| [v, i += 1] }
|
||||
@headers.unshift ['', i]
|
||||
rescue Exception => e
|
||||
flash[:error] = "Invalid CVS: could not read headers: #{e}"
|
||||
redirect_to :back
|
||||
return
|
||||
end
|
||||
|
||||
#save file for later
|
||||
# Save file for later
|
||||
begin
|
||||
uploaded_file = params[:file]
|
||||
@filename = sanitize_filename(uploaded_file.original_filename)
|
||||
|
|
@ -94,17 +93,17 @@ class DataController < ApplicationController
|
|||
all_tables['projects'] = current_user.projects.load
|
||||
|
||||
todo_tag_ids = Tag.find_by_sql([
|
||||
"SELECT DISTINCT tags.id "+
|
||||
"FROM tags, taggings, todos "+
|
||||
"WHERE todos.user_id=? "+
|
||||
"AND tags.id = taggings.tag_id " +
|
||||
"AND taggings.taggable_id = todos.id ", current_user.id])
|
||||
"SELECT DISTINCT tags.id
|
||||
FROM tags, taggings, todos
|
||||
WHERE todos.user_id = ?
|
||||
AND tags.id = taggings.tag_id
|
||||
AND taggings.taggable_id = todos.id", current_user.id])
|
||||
rec_todo_tag_ids = Tag.find_by_sql([
|
||||
"SELECT DISTINCT tags.id "+
|
||||
"FROM tags, taggings, recurring_todos "+
|
||||
"WHERE recurring_todos.user_id=? "+
|
||||
"AND tags.id = taggings.tag_id " +
|
||||
"AND taggings.taggable_id = recurring_todos.id ", current_user.id])
|
||||
"SELECT DISTINCT tags.id
|
||||
FROM tags, taggings, recurring_todos
|
||||
WHERE recurring_todos.user_id = ?
|
||||
AND tags.id = taggings.tag_id
|
||||
AND taggings.taggable_id = recurring_todos.id", current_user.id])
|
||||
tags = Tag.where("id IN (?) OR id IN (?)", todo_tag_ids, rec_todo_tag_ids)
|
||||
taggings = Tagging.where("tag_id IN (?) OR tag_id IN(?)", todo_tag_ids, rec_todo_tag_ids)
|
||||
|
||||
|
|
@ -114,7 +113,8 @@ class DataController < ApplicationController
|
|||
all_tables['recurring_todos'] = current_user.recurring_todos.load
|
||||
|
||||
result = all_tables.to_yaml
|
||||
result.gsub!(/\n/, "\r\n") # TODO: general functionality for line endings
|
||||
# TODO: general functionality for line endings
|
||||
result.gsub!(/\n/, "\r\n")
|
||||
send_data(result, :filename => "tracks_backup.yml", :type => 'text/plain')
|
||||
end
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ class DataController < ApplicationController
|
|||
csv << [todo.id, todo.context.name,
|
||||
todo.project_id.nil? ? "" : todo.project.name,
|
||||
todo.description,
|
||||
todo.notes, todo.tags.collect{|t| t.name}.join(', '),
|
||||
todo.notes, todo.tags.collect { |t| t.name }.join(', '),
|
||||
todo.created_at.to_formatted_s(:db),
|
||||
todo.due? ? todo.due.to_formatted_s(:db) : "",
|
||||
todo.completed_at? ? todo.completed_at.to_formatted_s(:db) : "",
|
||||
|
|
@ -163,17 +163,17 @@ class DataController < ApplicationController
|
|||
|
||||
def xml_export
|
||||
todo_tag_ids = Tag.find_by_sql([
|
||||
"SELECT DISTINCT tags.id "+
|
||||
"FROM tags, taggings, todos "+
|
||||
"WHERE todos.user_id=? "+
|
||||
"AND tags.id = taggings.tag_id " +
|
||||
"AND taggings.taggable_id = todos.id ", current_user.id])
|
||||
"SELECT DISTINCT tags.id
|
||||
FROM tags, taggings, todos
|
||||
WHERE todos.user_id = ?
|
||||
AND tags.id = taggings.tag_id
|
||||
AND taggings.taggable_id = todos.id", current_user.id])
|
||||
rec_todo_tag_ids = Tag.find_by_sql([
|
||||
"SELECT DISTINCT tags.id "+
|
||||
"FROM tags, taggings, recurring_todos "+
|
||||
"WHERE recurring_todos.user_id=? "+
|
||||
"AND tags.id = taggings.tag_id " +
|
||||
"AND taggings.taggable_id = recurring_todos.id ", current_user.id])
|
||||
"SELECT DISTINCT tags.id
|
||||
FROM tags, taggings, recurring_todos
|
||||
WHERE recurring_todos.user_id = ?
|
||||
AND tags.id = taggings.tag_id
|
||||
AND taggings.taggable_id = recurring_todos.id", current_user.id])
|
||||
tags = Tag.where("id IN (?) OR id IN (?)", todo_tag_ids, rec_todo_tag_ids)
|
||||
taggings = Tagging.where("tag_id IN (?) OR tag_id IN(?)", todo_tag_ids, rec_todo_tag_ids)
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ class DataController < ApplicationController
|
|||
|
||||
# adjusts time to utc
|
||||
def adjust_time(timestring)
|
||||
if (timestring == '') or (timestring == nil)
|
||||
if (timestring == '') || (timestring == nil)
|
||||
return nil
|
||||
else
|
||||
return Time.parse(timestring + 'UTC')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue