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

pulibrary / tigerdata-app / a3f50227-2424-4d41-8788-b953b9d6c802

24 Nov 2025 05:22PM UTC coverage: 70.412% (-17.7%) from 88.064%
a3f50227-2424-4d41-8788-b953b9d6c802

push

circleci

web-flow
Deduplicate department field from requests (#2229)

ref #2147

1 of 4 new or added lines in 1 file covered. (25.0%)

833 existing lines in 48 files now uncovered.

2344 of 3329 relevant lines covered (70.41%)

150.39 hits per line

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

100.0
/app/models/mediaflux/project_list_request.rb
1
# frozen_string_literal: true
2
module Mediaflux
2✔
3
  class ProjectListRequest < Request
2✔
4
    attr_reader :aql_query, :collection, :action, :deep_search, :iterator, :size
2✔
5

6
    # Constructor
7
    # @param session_token [String] the API token for the authenticated session
8
    # @param aql_query [String] Optional AQL query string
9
    # @param collection [Integer] Optional collection id
10
    # @param action [String] Optional, by default it uses get-name but it could also be get-meta to get all
11
    #                        the fields for the assets or `get-values` to get a limited list of fields.
12
    # @param deep_search [Bool] Optional, false by default. When true queries the collection and it subcollections.
13
    # @param iterator [Bool] Optional, true by default. When true returns an iterator.  When false returns a list of results
14
    def initialize(session_token:, aql_query: nil, action: "get-meta", deep_search: true)
2✔
15
      super(session_token: session_token)
10✔
16
      @aql_query = aql_query
10✔
17
      @collection = collection
10✔
18
      @action = action
10✔
19
      @deep_search = deep_search
10✔
20
      # For now we hard-code the size to infinity since only Administrators will fetch a large
21
      # number of projects and they should get them all. At some point in the future we might
22
      # want to implement pagination for this list but not now..
23
      @size = "infinity"
10✔
24
    end
25

26
    # Specifies the Mediaflux service to use when running a query
27
    # @return [String]
28
    def self.service
2✔
29
      "asset.query"
20✔
30
    end
31

32
    # Returns the iterator that could be used to fetch the data
33
    def results
2✔
34
      xml = response_xml
9✔
35
      assets = xml.xpath("/response/reply/result/asset")
9✔
36
      assets.map do |asset|
9✔
37
        metadata = asset.xpath("./meta//tigerdata:project", "tigerdata" => "tigerdata")
67✔
38
        {
39
          mediaflux_id: asset.xpath("@id").first.value,
67✔
40
          title: metadata.xpath("./Title").text,
41
          description: metadata.xpath("./Description").text,
42
          project_purpose: metadata.xpath("./ProjectPurpose").text,
43
          data_sponsor: metadata.xpath("./DataSponsor").text,
44
          data_manager: metadata.xpath("./DataManager").text,
45
          data_users: data_users_from_string(metadata.xpath("./DataUser").text),
46
          project_directory: metadata.xpath("./ProjectDirectory").text
47
        }
48
      end
49
    end
50

51
    private
2✔
52

53
      def build_http_request_body(name:)
2✔
54
        super do |xml|
20✔
55
          xml.args do
20✔
56
            xml.where aql_query if aql_query.present?
20✔
57
            xml.action action if action.present?
20✔
58
            xml.size size if size.present?
20✔
59
          end
60
        end
61
      end
62

63
      def data_users_from_string(users)
2✔
64
        return [] if users.blank?
67✔
UNCOV
65
        users.split(",").compact_blank
15✔
66
      end
67
  end
68
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