openaccess-apc 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e052242ed7b781cea0a4d318ecb246c4af62c022
4
- data.tar.gz: afa2a441d87730981498dcbd9f589ecd56f2723e
3
+ metadata.gz: a698e7c44a9866af8f475583905dbb70337678ad
4
+ data.tar.gz: 02ce906ba42fa03dea06ec3b9f171d6070d5bf68
5
5
  SHA512:
6
- metadata.gz: ff34a37d56c2c8eb51642c6ef9a09e6e8d50090d95fa91b51a19d1ce75e4e3f8dec3ce75150a4ff8504cf9439d6db2ea00aa0936422b4d9c56753ec7cb674256
7
- data.tar.gz: 00bc92546e0af2a73b4c37b711de361a8977bee04052d110547fa9772a9191c9e6d7a65aceec41b98b044ad5c24f08f864812e27ba635d87de06d9807dacf493
6
+ metadata.gz: 1c21a83d25ad8d8548142c1a6314216170f14e74dec2e26ce4b02beb8103f29303fa5081375a146ebd1118a5cf94c5473c87e2f8bbf4c4d3c014cf295dd528f6
7
+ data.tar.gz: c225213087854008087fba073508955f313083950d436594bbb63dd3bd141728b5ba70f5c99b7c4518adede734621affe95bf083e8c5ad271eac724cddfcfb97
@@ -86,7 +86,7 @@ module Puree
86
86
  params = {
87
87
  'associatedPersonUuids.uuid' => uuid,
88
88
  'rendering' => :system,
89
- 'window.size' => limit.to_s,
89
+ 'window.size' => (limit || 5).to_s,
90
90
  'window.offset' => (opts[:offset] || 0).to_s
91
91
  }
92
92
  self.class.query_params(params, **opts)
@@ -190,13 +190,12 @@ module OpenAccess
190
190
  # @option opts [Date, DateTime, String, Time] :created_start include
191
191
  # publications deposited on or after this date
192
192
  # @option opts [Integer, String] the Pure employee ID
193
- # @option opts [Integer] :results the number of eligible publications
194
- # required
193
+ # @return [Array<Hash>] the publications
195
194
  def self.publications_for_person(username = nil, **opts)
196
195
  person_uuid = person(username, employee_id: opts[:employee_id])
197
196
  publications_criteria(opts)
198
197
  pubs = @person_query.publications_extended(uuid: person_uuid, **opts)
199
- publications_summary(pubs[0..opts[:results]])
198
+ publications_summary(pubs)
200
199
  end
201
200
 
202
201
  # Private helpers
@@ -243,20 +242,19 @@ module OpenAccess
243
242
  workflow_state: pub.workflow_state
244
243
  }
245
244
  end
245
+ # rubocop:enable Metrics/MethodLength
246
246
  private_class_method :publication_summary
247
247
 
248
248
  # Sets the Puree person query criteria in an options hash
249
249
  # @param opts [Hash] the options hash
250
250
  # @return [Hash] the options hash
251
251
  def self.publications_criteria(opts)
252
- opts[:results] ||= 5
253
- opts[:limit] ||= opts[:results] * 10
252
+ opts[:limit] ||= 5
254
253
  opts[:order_by] = ['-created']
255
- # End date defaults to today; start date defaults to 6 months before end
256
- end_date = to_date(opts[:created_date_end], Date.today)
257
- start_date = to_date(opts[:created_date_start], end_date - 183)
258
- opts[:created_end] = end_date.to_s # YYYY-MM-DD
259
- opts[:created_start] = start_date.to_s
254
+ end_date = to_date(opts[:created_date_end])
255
+ start_date = to_date(opts[:created_date_start])
256
+ opts[:created_end] = end_date.to_s if end_date # YYYY-MM-DD
257
+ opts[:created_start] = start_date.to_s if start_date
260
258
  opts
261
259
  end
262
260
  private_class_method :publications_criteria
@@ -276,6 +274,7 @@ module OpenAccess
276
274
  # @param date [Object] the date representation
277
275
  # @param default [Date, nil] the default value if no date is supplied or
278
276
  # string parsing fails
277
+ # @return [Date] the date instance
279
278
  def self.to_date(date = nil, default = nil)
280
279
  return default if date.nil? || date.empty?
281
280
  return date if date.is_a?(Date)
@@ -1,5 +1,5 @@
1
1
  module OpenAccess
2
2
  module APC
3
- VERSION = '0.2.1'.freeze
3
+ VERSION = '0.2.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openaccess-apc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Digital Innovation, Lancaster University Library
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-23 00:00:00.000000000 Z
11
+ date: 2017-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ldap