<commit_before>require 'opal'
require 'jquery'
require 'opal-jquery'
require 'bootstrap'
require 'markdo/models/config'
require 'markdo/markdown_renderer'
require 'markdo/pencil_mustache'
require 'markdo/models/task_collection'

module Markdo
  class Client
    def run
      controller = TasksController.new
      controller.index
    end
  end

  class TasksController
    def index
      Promise.when(Config.fetch, TaskCollection.fetch).then do |config, task_collection|
        view = TasksView.new
        view.render(config, task_collection)
      end
    end
  end

  module BrowserDataSource
    def self.get(url)
      Promise.new.tap do |promise|
        cache_breaker = Time.now.to_i
        url_with_cache_breaker = [url, cache_breaker].join('?')

        HTTP.get(url_with_cache_breaker) do |response|
          if 200 == response.status_code
            promise.resolve(response)<commit_msg>Refactor: Move view preparation before GET requests<commit_after>require 'opal'
require 'jquery'
require 'opal-jquery'
require 'bootstrap'
require 'markdo/models/config'
require 'markdo/markdown_renderer'
require 'markdo/pencil_mustache'
require 'markdo/models/task_collection'

module Markdo
  class Client
    def run
      controller = TasksController.new
      controller.index
    end
  end

  class TasksController
    def index
      view = TasksView.new

      Promise.when(Config.fetch, TaskCollection.fetch).then do |config, task_collection|
        view.render(config, task_collection)
      end
    end
  end

  module BrowserDataSource
    def self.get(url)
      Promise.new.tap do |promise|
        cache_breaker = Time.now.to_i
        url_with_cache_breaker = [url, cache_breaker].join('?')

        HTTP.get(url_with_cache_breaker) do |response|
          if 200 == response.status_code
            promise.resolve(response)
{'fraction_non_alphanumeric': 0.0828370330265295, 'fraction_numerical': 0.0032485110990795887, 'mean_word_length': 3.219178082191781, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '727620', 'n_tokens_mistral': 572, 'n_tokens_neox': 543, 'n_words': 129}