<commit_before>require 'sinatra'
require 'json'
require 'config/db/seed'

get '/projects' do
  JSON.dump(Seed::DB[:projects].map { |project|
    project_with_execution_cycle = project.clone
    project_with_execution_cycle[:currentExecutionCycle] = Seed::DB[:executionCycles]
                                          .find { |x| x[:projectId] == project[:id] && x[:stoppedAt].nil? }
    project_with_execution_cycle
  })
end

get '/projects/:id' do |id|
  found_project = Seed::DB[:projects].select { |project| project[:id] == id.to_s.to_i }.first
  found_project ? JSON.dump(found_project) : not_found
end<commit_msg>Fix date to ISO format<commit_after>require 'sinatra'
require 'json'
require 'config/db/seed'

get '/projects' do
  JSON.dump(Seed::DB[:projects].map { |project|
    project_with_execution_cycle = project.clone
    currentExecutionCycle = Seed::DB[:executionCycles].find { |x| x[:projectId] == project[:id] && x[:stoppedAt].nil? }
    unless currentExecutionCycle.nil?
      project_with_execution_cycle[:currentExecutionCycle] = currentExecutionCycle.clone
      project_with_execution_cycle[:currentExecutionCycle][:startedAt] =
          project_with_execution_cycle[:currentExecutionCycle][:startedAt].strftime('%Y-%m-%dT%H:%M:%S.%L%z')
    end

    unless project_with_execution_cycle[:lastExecutionCycle].nil?
      project_with_execution_cycle[:lastExecutionCycle] = project_with_execution_cycle[:lastExecutionCycle].clone
      project_with_execution_cycle[:lastExecutionCycle][:startedAt] =
          project_with_execution_cycle[:lastExecutionCycle][:startedAt].strftime('%Y-%m-%dT%H:%M:%S.%L%z')
      if project_with_execution_cycle[:lastExecutionCycle][:stoppedAt]
        project_with_execution_cycle[:lastExecutionCycle][:stoppedAt] =
            project_with_execution_cycle[:lastExecutionCycle][:stoppedAt].strftime('%Y-%m-%dT%H:%M:%S.%L%z')
      end
    end

    project_with_execution_cycle
  })
end

get '/projects/:id' do |id|
  found_project = Seed::DB[:projects].find { |project| project[:id] == id.to_s.to_i }
  found_project ? JSON.dump(found_project) : not_found
end
{'fraction_non_alphanumeric': 0.1387310606060606, 'fraction_numerical': 0.0, 'mean_word_length': 5.054441260744985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5975605', 'n_tokens_mistral': 712, 'n_tokens_neox': 677, 'n_words': 92}