Class: Athenian::PullRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/athenian/models/pull_request.rb

Overview

Details of a pull request. All the attributes, stats and events correspond to "today", not ‘date_to`, *except for the PR stages `wip`, `reviewing`, `merging`, `releasing`*, which correspond to `date_to`.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ PullRequest

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/athenian/models/pull_request.rb', line 185

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, 'The input argument (attributes) must be a hash in `Athenian::PullRequest` initialize method'
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Athenian::PullRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'repository')
    self.repository = attributes[:'repository']
  end

  if attributes.key?(:'number')
    self.number = attributes[:'number']
  end

  if attributes.key?(:'title')
    self.title = attributes[:'title']
  end

  if attributes.key?(:'size_added')
    self.size_added = attributes[:'size_added']
  end

  if attributes.key?(:'size_removed')
    self.size_removed = attributes[:'size_removed']
  end

  if attributes.key?(:'files_changed')
    self.files_changed = attributes[:'files_changed']
  end

  if attributes.key?(:'created')
    self.created = attributes[:'created']
  end

  if attributes.key?(:'updated')
    self.updated = attributes[:'updated']
  end

  if attributes.key?(:'closed')
    self.closed = attributes[:'closed']
  end

  if attributes.key?(:'comments')
    self.comments = attributes[:'comments']
  end

  if attributes.key?(:'commits')
    self.commits = attributes[:'commits']
  end

  if attributes.key?(:'review_requested')
    self.review_requested = attributes[:'review_requested']
  end

  if attributes.key?(:'first_review')
    self.first_review = attributes[:'first_review']
  end

  if attributes.key?(:'approved')
    self.approved = attributes[:'approved']
  end

  if attributes.key?(:'review_comments')
    self.review_comments = attributes[:'review_comments']
  end

  if attributes.key?(:'reviews')
    self.reviews = attributes[:'reviews']
  end

  if attributes.key?(:'merged')
    self.merged = attributes[:'merged']
  end

  if attributes.key?(:'merged_with_failed_check_runs')
    if (value = attributes[:'merged_with_failed_check_runs']).is_a?(Array)
      self.merged_with_failed_check_runs = value
    end
  end

  if attributes.key?(:'released')
    self.released = attributes[:'released']
  end

  if attributes.key?(:'release_url')
    self.release_url = attributes[:'release_url']
  end

  if attributes.key?(:'deployments')
    if (value = attributes[:'deployments']).is_a?(Array)
      self.deployments = value
    end
  end

  if attributes.key?(:'stage_timings')
    self.stage_timings = attributes[:'stage_timings']
  end

  if attributes.key?(:'events_time_machine')
    if (value = attributes[:'events_time_machine']).is_a?(Array)
      self.events_time_machine = value
    end
  end

  if attributes.key?(:'stages_time_machine')
    if (value = attributes[:'stages_time_machine']).is_a?(Array)
      self.stages_time_machine = value
    end
  end

  if attributes.key?(:'events_now')
    if (value = attributes[:'events_now']).is_a?(Array)
      self.events_now = value
    end
  end

  if attributes.key?(:'stages_now')
    if (value = attributes[:'stages_now']).is_a?(Array)
      self.stages_now = value
    end
  end

  if attributes.key?(:'participants')
    if (value = attributes[:'participants']).is_a?(Array)
      self.participants = value
    end
  end

  if attributes.key?(:'labels')
    if (value = attributes[:'labels']).is_a?(Array)
      self.labels = value
    end
  end

  if attributes.key?(:'jira')
    if (value = attributes[:'jira']).is_a?(Array)
      self.jira = value
    end
  end
end

Instance Attribute Details

#approvedObject

When this PR was approved.



56
57
58
# File 'lib/athenian/models/pull_request.rb', line 56

def approved
  @approved
end

#closedObject

When this PR was last closed.



41
42
43
# File 'lib/athenian/models/pull_request.rb', line 41

def closed
  @closed
end

#commentsObject

Number of regular (not review) comments in this PR.



44
45
46
# File 'lib/athenian/models/pull_request.rb', line 44

def comments
  @comments
end

#commitsObject

Number of commits in this PR.



47
48
49
# File 'lib/athenian/models/pull_request.rb', line 47

def commits
  @commits
end

#createdObject

When this PR was created.



35
36
37
# File 'lib/athenian/models/pull_request.rb', line 35

def created
  @created
end

#deploymentsObject

List of deployments that contain this PR.



77
78
79
# File 'lib/athenian/models/pull_request.rb', line 77

def deployments
  @deployments
end

#events_nowObject

List of PR events that ever happened.



88
89
90
# File 'lib/athenian/models/pull_request.rb', line 88

def events_now
  @events_now
end

#events_time_machineObject

List of PR events which happened until ‘date_to`. `date_from` does not matter.



82
83
84
# File 'lib/athenian/models/pull_request.rb', line 82

def events_time_machine
  @events_time_machine
end

#files_changedObject

Number of files changed in this PR.



32
33
34
# File 'lib/athenian/models/pull_request.rb', line 32

def files_changed
  @files_changed
end

#first_reviewObject

When the first review of this PR happened.



53
54
55
# File 'lib/athenian/models/pull_request.rb', line 53

def first_review
  @first_review
end

#jiraObject

List of linked JIRA issues.



100
101
102
# File 'lib/athenian/models/pull_request.rb', line 100

def jira
  @jira
end

#labelsObject

List of PR labels.



97
98
99
# File 'lib/athenian/models/pull_request.rb', line 97

def labels
  @labels
end

#mergedObject

When this PR was merged.



65
66
67
# File 'lib/athenian/models/pull_request.rb', line 65

def merged
  @merged
end

#merged_with_failed_check_runsObject

PR was merged with these failed check runs.



68
69
70
# File 'lib/athenian/models/pull_request.rb', line 68

def merged_with_failed_check_runs
  @merged_with_failed_check_runs
end

#numberObject

PR number.



20
21
22
# File 'lib/athenian/models/pull_request.rb', line 20

def number
  @number
end

#participantsObject

List of developers related to this PR.



94
95
96
# File 'lib/athenian/models/pull_request.rb', line 94

def participants
  @participants
end

#release_urlObject

URL of the earliest release that includes this merged PR.



74
75
76
# File 'lib/athenian/models/pull_request.rb', line 74

def release_url
  @release_url
end

#releasedObject

When this PR was released.



71
72
73
# File 'lib/athenian/models/pull_request.rb', line 71

def released
  @released
end

#repositoryObject

PR is/was open in this repository.



17
18
19
# File 'lib/athenian/models/pull_request.rb', line 17

def repository
  @repository
end

#review_commentsObject

Number of review comments this PR received. A review comment is left at a specific line in a specific file. In other words: review summaries are not considered review comments; refer to ‘reviews`. Comments by the PR author are considered as `comments`, not as `review_comments`.



59
60
61
# File 'lib/athenian/models/pull_request.rb', line 59

def review_comments
  @review_comments
end

#review_requestedObject

When was the first time the author of this PR requested a review.



50
51
52
# File 'lib/athenian/models/pull_request.rb', line 50

def review_requested
  @review_requested
end

#reviewsObject

Number of times this PR was reviewed. Reviews by the PR author are not taken into account.



62
63
64
# File 'lib/athenian/models/pull_request.rb', line 62

def reviews
  @reviews
end

#size_addedObject

Overall number of lines added.



26
27
28
# File 'lib/athenian/models/pull_request.rb', line 26

def size_added
  @size_added
end

#size_removedObject

Overall number of lines removed.



29
30
31
# File 'lib/athenian/models/pull_request.rb', line 29

def size_removed
  @size_removed
end

#stage_timingsObject

Returns the value of attribute stage_timings.



79
80
81
# File 'lib/athenian/models/pull_request.rb', line 79

def stage_timings
  @stage_timings
end

#stages_nowObject

List of current PR stages (normally, of length 1).



91
92
93
# File 'lib/athenian/models/pull_request.rb', line 91

def stages_now
  @stages_now
end

#stages_time_machineObject

List of PR stages as of ‘date_to` (normally, of length 1).



85
86
87
# File 'lib/athenian/models/pull_request.rb', line 85

def stages_time_machine
  @stages_time_machine
end

#titleObject

Title of the PR.



23
24
25
# File 'lib/athenian/models/pull_request.rb', line 23

def title
  @title
end

#updatedObject

When this PR was last updated.



38
39
40
# File 'lib/athenian/models/pull_request.rb', line 38

def updated
  @updated
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



138
139
140
# File 'lib/athenian/models/pull_request.rb', line 138

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/athenian/models/pull_request.rb', line 103

def self.attribute_map
  {
    :'repository' => :'repository',
    :'number' => :'number',
    :'title' => :'title',
    :'size_added' => :'size_added',
    :'size_removed' => :'size_removed',
    :'files_changed' => :'files_changed',
    :'created' => :'created',
    :'updated' => :'updated',
    :'closed' => :'closed',
    :'comments' => :'comments',
    :'commits' => :'commits',
    :'review_requested' => :'review_requested',
    :'first_review' => :'first_review',
    :'approved' => :'approved',
    :'review_comments' => :'review_comments',
    :'reviews' => :'reviews',
    :'merged' => :'merged',
    :'merged_with_failed_check_runs' => :'merged_with_failed_check_runs',
    :'released' => :'released',
    :'release_url' => :'release_url',
    :'deployments' => :'deployments',
    :'stage_timings' => :'stage_timings',
    :'events_time_machine' => :'events_time_machine',
    :'stages_time_machine' => :'stages_time_machine',
    :'events_now' => :'events_now',
    :'stages_now' => :'stages_now',
    :'participants' => :'participants',
    :'labels' => :'labels',
    :'jira' => :'jira'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



611
612
613
# File 'lib/athenian/models/pull_request.rb', line 611

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



178
179
180
181
# File 'lib/athenian/models/pull_request.rb', line 178

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/athenian/models/pull_request.rb', line 143

def self.openapi_types
  {
    :'repository' => :'String',
    :'number' => :'Integer',
    :'title' => :'String',
    :'size_added' => :'Integer',
    :'size_removed' => :'Integer',
    :'files_changed' => :'Integer',
    :'created' => :'Time',
    :'updated' => :'Time',
    :'closed' => :'Time',
    :'comments' => :'Integer',
    :'commits' => :'Integer',
    :'review_requested' => :'Time',
    :'first_review' => :'Time',
    :'approved' => :'Time',
    :'review_comments' => :'Integer',
    :'reviews' => :'Integer',
    :'merged' => :'Time',
    :'merged_with_failed_check_runs' => :'Array<String>',
    :'released' => :'Time',
    :'release_url' => :'String',
    :'deployments' => :'Array<String>',
    :'stage_timings' => :'StageTimings',
    :'events_time_machine' => :'Array<PullRequestEvent>',
    :'stages_time_machine' => :'Array<PullRequestStage>',
    :'events_now' => :'Array<PullRequestEvent>',
    :'stages_now' => :'Array<PullRequestStage>',
    :'participants' => :'Array<PullRequestParticipant>',
    :'labels' => :'Array<PullRequestLabel>',
    :'jira' => :'Array<LinkedJIRAIssue>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
# File 'lib/athenian/models/pull_request.rb', line 562

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      repository == o.repository &&
      number == o.number &&
      title == o.title &&
      size_added == o.size_added &&
      size_removed == o.size_removed &&
      files_changed == o.files_changed &&
      created == o.created &&
      updated == o.updated &&
      closed == o.closed &&
      comments == o.comments &&
      commits == o.commits &&
      review_requested == o.review_requested &&
      first_review == o.first_review &&
      approved == o.approved &&
      review_comments == o.review_comments &&
      reviews == o.reviews &&
      merged == o.merged &&
      merged_with_failed_check_runs == o.merged_with_failed_check_runs &&
      released == o.released &&
      release_url == o.release_url &&
      deployments == o.deployments &&
      stage_timings == o.stage_timings &&
      events_time_machine == o.events_time_machine &&
      stages_time_machine == o.stages_time_machine &&
      events_now == o.events_now &&
      stages_now == o.stages_now &&
      participants == o.participants &&
      labels == o.labels &&
      jira == o.jira
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
# File 'lib/athenian/models/pull_request.rb', line 642

def _deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = Athenian.const_get(type)
    klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



713
714
715
716
717
718
719
720
721
722
723
724
725
# File 'lib/athenian/models/pull_request.rb', line 713

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
# File 'lib/athenian/models/pull_request.rb', line 618

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  self.class.openapi_types.each_pair do |key, type|
    if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      self.send("#{key}=", nil)
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


598
599
600
# File 'lib/athenian/models/pull_request.rb', line 598

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



604
605
606
# File 'lib/athenian/models/pull_request.rb', line 604

def hash
  [repository, number, title, size_added, size_removed, files_changed, created, updated, closed, comments, commits, review_requested, first_review, approved, review_comments, reviews, merged, merged_with_failed_check_runs, released, release_url, deployments, stage_timings, events_time_machine, stages_time_machine, events_now, stages_now, participants, labels, jira].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/athenian/models/pull_request.rb', line 335

def list_invalid_properties
  invalid_properties = Array.new
  if @repository.nil?
    invalid_properties.push('invalid value for "repository", repository cannot be nil.')
  end

  if @number.nil?
    invalid_properties.push('invalid value for "number", number cannot be nil.')
  end

  if @number < 1
    invalid_properties.push('invalid value for "number", must be greater than or equal to 1.')
  end

  if @title.nil?
    invalid_properties.push('invalid value for "title", title cannot be nil.')
  end

  if @size_added.nil?
    invalid_properties.push('invalid value for "size_added", size_added cannot be nil.')
  end

  if @size_added < 0
    invalid_properties.push('invalid value for "size_added", must be greater than or equal to 0.')
  end

  if @size_removed.nil?
    invalid_properties.push('invalid value for "size_removed", size_removed cannot be nil.')
  end

  if @size_removed < 0
    invalid_properties.push('invalid value for "size_removed", must be greater than or equal to 0.')
  end

  if @files_changed.nil?
    invalid_properties.push('invalid value for "files_changed", files_changed cannot be nil.')
  end

  if @files_changed < 0
    invalid_properties.push('invalid value for "files_changed", must be greater than or equal to 0.')
  end

  if @created.nil?
    invalid_properties.push('invalid value for "created", created cannot be nil.')
  end

  if @updated.nil?
    invalid_properties.push('invalid value for "updated", updated cannot be nil.')
  end

  if @comments.nil?
    invalid_properties.push('invalid value for "comments", comments cannot be nil.')
  end

  if @comments < 0
    invalid_properties.push('invalid value for "comments", must be greater than or equal to 0.')
  end

  if @commits.nil?
    invalid_properties.push('invalid value for "commits", commits cannot be nil.')
  end

  if @commits < 0
    invalid_properties.push('invalid value for "commits", must be greater than or equal to 0.')
  end

  if !@review_comments.nil? && @review_comments < 0
    invalid_properties.push('invalid value for "review_comments", must be greater than or equal to 0.')
  end

  if !@reviews.nil? && @reviews < 0
    invalid_properties.push('invalid value for "reviews", must be greater than or equal to 0.')
  end

  if @stage_timings.nil?
    invalid_properties.push('invalid value for "stage_timings", stage_timings cannot be nil.')
  end

  if @events_now.nil?
    invalid_properties.push('invalid value for "events_now", events_now cannot be nil.')
  end

  if @stages_now.nil?
    invalid_properties.push('invalid value for "stages_now", stages_now cannot be nil.')
  end

  if @participants.nil?
    invalid_properties.push('invalid value for "participants", participants cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



689
690
691
# File 'lib/athenian/models/pull_request.rb', line 689

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



695
696
697
698
699
700
701
702
703
704
705
706
707
# File 'lib/athenian/models/pull_request.rb', line 695

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



683
684
685
# File 'lib/athenian/models/pull_request.rb', line 683

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'lib/athenian/models/pull_request.rb', line 430

def valid?
  return false if @repository.nil?
  return false if @number.nil?
  return false if @number < 1
  return false if @title.nil?
  return false if @size_added.nil?
  return false if @size_added < 0
  return false if @size_removed.nil?
  return false if @size_removed < 0
  return false if @files_changed.nil?
  return false if @files_changed < 0
  return false if @created.nil?
  return false if @updated.nil?
  return false if @comments.nil?
  return false if @comments < 0
  return false if @commits.nil?
  return false if @commits < 0
  return false if !@review_comments.nil? && @review_comments < 0
  return false if !@reviews.nil? && @reviews < 0
  return false if @stage_timings.nil?
  return false if @events_now.nil?
  return false if @stages_now.nil?
  return false if @participants.nil?
  true
end