1class NotesController < ApplicationController
 
2    
 
3    before_action :authenticate
 
4    
 
5    #
 
6    
  • Complexity 4 » saikuro
  • Method "getNotesList" has 24 lines. It should have 20 or less. » roodi
  • Method name "getNotesList" should match pattern /^[_a-z<>=\[\]|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/ » roodi
  • DuplicateMethodCall - calls n.created_at 2 times » reek
  • DuplicateMethodCall - calls n.created_at.to_s 2 times » reek
  • TooManyStatements - has approx 13 statements » reek
  • UncommunicativeMethodName - has the name 'getNotesList' » reek
  • UncommunicativeVariableName - has the variable name 'h' » reek
  • UncommunicativeVariableName - has the variable name 'k' » reek
  • UncommunicativeVariableName - has the variable name 'n' » reek
  • UncommunicativeVariableName - has the variable name 'v' » reek
  • FeatureEnvy - refers to n more than self » reek
7    def getNotesList
 
8    #Todo
 
 9    pid = params[:project_id]
 
10    uid = session[:user_id]
 
11    notes = Note.where("user_id = ? AND project_id = ? ",uid,pid).order("created_at desc").all
 
12    note = Hash.new do |h,k|
 
13            h[k] = []
 
14    end
 
15    notes.each do |n|
 
16        date =  n.created_at.to_s[/([\d\-]*)\s(.*)/,1]
 
17        time =  n.created_at.to_s[/(.*)\s([\d\:]*)/,2]
 
18        note[date] << {
 
19            :content => n.content,
 
20            :time => time,
 
21            :type => n.category
 
22        }
 
23    end
 
24    data = []
 
25    note.each do |k,v|
 
26        data += [{
 
27            :time => k,
 
28            :notes => v
 
29        }]
 
30    end
 
31    render :json => {
 
32        :code => 0,
 
33        :data => data
 
34    }
 
35    end
 
 
37end