• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sleede / fab-manager / #106

pending completion
#106

push

coveralls-ruby

sylvainbx
Merge branch 'dev' for release 6.0.0

704 of 704 new or added lines in 168 files covered. (100.0%)

7919 of 13474 relevant lines covered (58.77%)

15.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/controllers/api/statistics_controller.rb
1
# frozen_string_literal: true
2

3
# API Controller for various statistical resources (gateway to elasticsearch DB)
4
class API::StatisticsController < API::APIController
×
5
  before_action :authenticate_user!
×
6

7
  def index
×
8
    authorize :statistic, :index?
×
9
    @statistics = StatisticIndex.all
×
10
  end
×
11

12
  %w[account event machine project subscription training user space order].each do |path|
×
13
    class_eval %{
×
14
      def #{path}                                                       # def account
×
15
        authorize :statistic, :#{path}?                                 #   authorize :statistic, :account
×
16
        render json: Statistics::QueryService.query('#{path}', request) #   render json: Statistics::QueryService.query('account', request)
×
17
      end                                                               # end
×
18

19
      def export_#{path}                                                # def export_account
×
20
        authorize :statistic, :export_#{path}?                          # authorize :statistic, :export_account?
×
21

22
        @export = Statistics::QueryService.export('#{path}', params,    # @export = Statistics::QueryService.export('account', params,
×
23
                                                  current_user)
×
24
        if @export.is_a?(Export)
×
25
          if @export.save
×
26
            render json: { export_id: @export.id }, status: :ok
×
27
          else
×
28
            render json: @export.errors, status: :unprocessable_entity
×
29
          end
×
30
        else
×
31
          send_file @export,
×
32
                    type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
×
33
                    disposition: 'attachment'
×
34
        end
×
35
      end
×
36
    }, __FILE__, __LINE__ - 23
×
37
  end
×
38

39
  def export_global
×
40
    authorize :statistic, :export_global?
×
41

42
    @export = Statistics::QueryService.export('global', params, current_user)
×
43
    if @export.is_a?(Export)
×
44
      if @export.save
×
45
        render json: { export_id: @export.id }, status: :ok
×
46
      else
×
47
        render json: @export.errors, status: :unprocessable_entity
×
48
      end
×
49
    else
×
50
      send_file @export,
×
51
                type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
×
52
                disposition: 'attachment'
×
53
    end
×
54
  end
×
55

56
  def scroll
×
57
    authorize :statistic, :scroll?
×
58

59
    results = Elasticsearch::Model.client.scroll scroll: params[:scroll], scroll_id: params[:scrollId]
×
60
    render json: results
×
61
  end
×
62
end
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc