blob: b04cce0a7ff17e2449bc3dc09ec12c18c4413089 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package com.getbootstrap.no_carrier.github
import java.time.{Clock, Instant, Duration}
import com.jcabi.github.Issue
import com.getbootstrap.no_carrier.util._
import com.getbootstrap.no_carrier.github.util._
import InstantOrdering._
class FancyIssue(val issue: Issue, val label: String, val timeout: Duration)(implicit clock: Clock) {
lazy val lastLabelledAt: Instant = issue.lastLabelledWithAt(label).get
lazy val lastCommentedOnAt: Option[Instant] = issue.smartComments.map{ _.createdAt.toInstant }.lastOption
lazy val lastClosedAt: Option[Instant] = issue.smartEvents.filter{ _.isClosed }.map{ _.createdAt.toInstant }.lastOption
lazy val hasSubsequentComment: Boolean = lastCommentedOnAt match {
case None => false
case Some(commentedAt) => lastLabelledAt < commentedAt
}
lazy val wasClosedAfterLabelling: Boolean = lastClosedAt match {
case None => false
case Some(closedAt) => lastLabelledAt < closedAt
}
lazy val isPastDeadline: Boolean = lastLabelledAt isBeyondTimeout timeout
lazy val opNeverDelivered: Boolean = isPastDeadline && !wasClosedAfterLabelling && !hasSubsequentComment
}
|