Sha256: eed2c42474f9207cee644ae534b489cba5ec95335ccfdd92f44e7c7232fbc0f6

Contents?: true

Size: 1.23 KB

Versions: 22

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require_relative '../../models/entry_group'
require_relative '../../services/entry_group/exporter_service'
require_relative '../base_presenter_ex'

module Dsu
  module Presenters
    module Export
      class DatesPresenter < BasePresenterEx
        attr_reader :export_file_path

        def initialize(from:, to:, options: {})
          super(options: options)

          @from = from
          @to = to

          self.options[:times] = [from, to]
        end

        def respond(response:)
          return false unless response

          @export_file_path = exporter_service.call
        end

        def nothing_to_export?
          entry_groups.empty?
        end

        def entry_group_count
          entry_groups&.count || 0
        end

        private

        attr_reader :from, :to, :options

        def entry_groups
          Models::EntryGroup.entry_groups(between: [from, to])
        end

        def exporter_service
          Services::EntryGroup::ExporterService.new(project_name: project_name,
            entry_groups: entry_groups, options: options)
        end

        def project_name
          @project_name ||= Models::Project.current_project.project_name
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
dsu-3.0.5 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.4 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.3 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.1 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.beta.3 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.beta.2 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.beta.1 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.beta.0 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.alpha.12 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.alpha.11 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.alpha.10 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.alpha.9 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.alpha.8 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.alpha.7 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.alpha.6 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.alpha.5 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.alpha.4 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.alpha.3 lib/dsu/presenters/export/dates_presenter.rb
dsu-3.0.0.alpha.2 lib/dsu/presenters/export/dates_presenter.rb