Serialize last_fetched_at as a string with seconds
This commit is contained in:
		
							parent
							
								
									7ec5ff4dba
								
							
						
					
					
						commit
						285926918b
					
				| 
						 | 
				
			
			@ -5,7 +5,7 @@ class Projects::NotesController < Projects::ApplicationController
 | 
			
		|||
  before_filter :authorize_admin_note!, only: [:update, :destroy]
 | 
			
		||||
 | 
			
		||||
  def index
 | 
			
		||||
    current_fetched_at = Time.now
 | 
			
		||||
    current_fetched_at = Time.now.to_i
 | 
			
		||||
    @notes = NotesFinder.new.execute(project, current_user, params)
 | 
			
		||||
 | 
			
		||||
    notes_json = { notes: [], last_fetched_at: current_fetched_at }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,7 @@ class NotesFinder
 | 
			
		|||
  def execute(project, current_user, params)
 | 
			
		||||
    target_type = params[:target_type]
 | 
			
		||||
    target_id   = params[:target_id]
 | 
			
		||||
    last_fetched_at = params.fetch(:last_fetched_at)
 | 
			
		||||
    last_fetched_at = Time.at(params.fetch(:last_fetched_at).to_i)
 | 
			
		||||
 | 
			
		||||
    notes = case target_type
 | 
			
		||||
    when "commit"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,4 +7,4 @@
 | 
			
		|||
  = render "projects/notes/form"
 | 
			
		||||
 | 
			
		||||
:javascript
 | 
			
		||||
  new Notes("#{project_notes_path(target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, Time.now)
 | 
			
		||||
  new Notes("#{project_notes_path(target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, #{Time.now.to_i})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,7 @@ describe NotesFinder do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  describe :execute do
 | 
			
		||||
    let(:params)  { { target_id: commit.id, target_type: 'commit', last_fetched_at: 1.hour.ago } }
 | 
			
		||||
    let(:params)  { { target_id: commit.id, target_type: 'commit', last_fetched_at: 1.hour.ago.to_i } }
 | 
			
		||||
 | 
			
		||||
    before do
 | 
			
		||||
      note1
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue