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

pulibrary / tigerdata-app / b10fccf6-5ec9-4665-936f-349cab0ca8ed

28 Oct 2025 02:06PM UTC coverage: 87.382% (-3.9%) from 91.294%
b10fccf6-5ec9-4665-936f-349cab0ca8ed

Pull #2057

circleci

hectorcorrea
Force a change
Pull Request #2057: Dashboard displays projects straights from Mediaflux

49 of 69 new or added lines in 4 files covered. (71.01%)

930 existing lines in 39 files now uncovered.

2694 of 3083 relevant lines covered (87.38%)

296.77 hits per line

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

92.86
/app/models/mediaflux/iterator_request.rb
1
# frozen_string_literal: true
UNCOV
2
module Mediaflux
2✔
UNCOV
3
  class IteratorRequest < Request
2✔
4
    # Constructor
5
    # @param session_token [String] the API token for the authenticated session
6
    # @iterator [Int] The iterator returned by Mediaflux (via QueryRequest)
UNCOV
7
    def initialize(session_token:, iterator:, action: "get-values", size: nil)
2✔
UNCOV
8
      super(session_token: session_token)
15✔
UNCOV
9
      @iterator = iterator
15✔
UNCOV
10
      @size = size
15✔
UNCOV
11
      @action = action
15✔
UNCOV
12
    end
13

14
    # Specifies the Mediaflux service to use when running a query
15
    # @return [String]
UNCOV
16
    def self.service
2✔
UNCOV
17
      "asset.query.iterate"
30✔
UNCOV
18
    end
19

20
    # Returns hash with the files fetched in this iteration as well as a flag on whether we are
21
    # done iterating (complete=true) or if we need to keep iterating
UNCOV
22
    def result
2✔
UNCOV
23
      xml = response_xml
15✔
UNCOV
24
      {
UNCOV
25
        files: parse_files(xml),
15✔
UNCOV
26
        complete: xml.xpath("/response/reply/result/iterated/@complete").text == "true",
UNCOV
27
        count: xml.xpath("/response/reply/result/iterated").text.to_i
UNCOV
28
      }
UNCOV
29
    end
30

UNCOV
31
    private
2✔
32

UNCOV
33
      def build_http_request_body(name:)
2✔
UNCOV
34
        super do |xml|
30✔
UNCOV
35
          xml.args do
30✔
UNCOV
36
            xml.id @iterator
30✔
UNCOV
37
            xml.size @size if @size.present?
30✔
UNCOV
38
          end
UNCOV
39
        end
UNCOV
40
      end
41

UNCOV
42
      def parse_files(xml)
2✔
UNCOV
43
        case @action
15✔
UNCOV
44
        when "get-name"
UNCOV
45
          parse_get_name(xml)
1✔
UNCOV
46
        when "get-meta"
UNCOV
47
          parse_get_meta(xml)
1✔
UNCOV
48
        when "get-values"
UNCOV
49
          parse_get_values(xml)
13✔
UNCOV
50
        else
51
          raise "Cannot parse result. Unknow action: #{@action}."
×
UNCOV
52
        end
UNCOV
53
      end
54

55
      # Extracts file information when the request was made with the "action: get-name" parameter
UNCOV
56
      def parse_get_name(xml)
2✔
UNCOV
57
        files = []
1✔
UNCOV
58
        xml.xpath("/response/reply/result/name").each do |node|
1✔
59
          file = Mediaflux::Asset.new(
×
UNCOV
60
            id: node.xpath("./@id").text,
UNCOV
61
            name: node.text,
UNCOV
62
            collection: node.xpath("./@collection").text == "true"
UNCOV
63
          )
64
          files << file
×
UNCOV
65
        end
UNCOV
66
        files
1✔
UNCOV
67
      end
68

69
      # Extracts file information when the request was made with the "action: get-meta" parameter
UNCOV
70
      def parse_get_meta(xml)
2✔
UNCOV
71
        files = []
1✔
UNCOV
72
        xml.xpath("/response/reply/result/asset").each do |node|
1✔
UNCOV
73
          file = Mediaflux::Asset.new(
2✔
UNCOV
74
            id: node.xpath("./@id").text,
UNCOV
75
            name: node.xpath("./name").text,
UNCOV
76
            path: node.xpath("./path").text,
UNCOV
77
            collection: node.xpath("./@collection").text == "true",
UNCOV
78
            size: node.xpath("./content/@total-size").text.to_i,
UNCOV
79
            last_modified_mf: node.xpath("mtime").text
UNCOV
80
          )
UNCOV
81
          files << file
2✔
UNCOV
82
        end
UNCOV
83
        files
1✔
UNCOV
84
      end
85

86
      # Extracts file information when the request was made with the "action: get-values" parameter
87
      # Notice that this code is coupled with the fields defined in QueryRequest.
UNCOV
88
      def parse_get_values(xml)
2✔
UNCOV
89
        files = []
13✔
UNCOV
90
        xml.xpath("/response/reply/result/asset").each do |node|
13✔
UNCOV
91
          file = Mediaflux::Asset.new(
10✔
UNCOV
92
            id: node.xpath("./@id").text,
UNCOV
93
            name: node.xpath("./name").text,
UNCOV
94
            path: node.xpath("./path").text,
UNCOV
95
            collection: node.xpath("./collection").text == "true",
UNCOV
96
            size: node.xpath("./total-size").text.to_i,
UNCOV
97
            last_modified_mf: node.xpath("mtime").text
UNCOV
98
          )
UNCOV
99
          files << file
10✔
UNCOV
100
        end
UNCOV
101
        files
13✔
UNCOV
102
      end
UNCOV
103
  end
UNCOV
104
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