Skip to content

Commit

Permalink
#1215 catch and log RuntimeException on reviewing assigned tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Aug 23, 2021
1 parent 9f9b2d3 commit 2230f93
Showing 1 changed file with 71 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public void unassignedTasks(final Event event) {
//@checkstyle IllegalCatch (2 lines)
} catch (final RuntimeException exception) {
LOG.error(
"Problem while checking the unassigned Task #"
"Problem while checking the UNASSIGNED Task #"
+ task.issueId() + " of Project " + project.repoFullName()
+ " at " + project.provider() + ". Ignoring and moving on.",
exception
Expand Down Expand Up @@ -519,78 +519,90 @@ public void assignedTasks(final Event event) {
for(final Task task : project.tasks()) {
final Contributor assignee = task.assignee();
if(assignee != null) {
final Issue issue = task.issue();
if(issue.isClosed()) {
LOG.debug(
"Task #" + issue.issueId()
+ " of Contributor " + assignee.username()
+ " is closed. Invoicing... "
);
final BigDecimal value = task.value();
final InvoicedTask invoiced = task.contract()
.invoices()
.active()
.register(
task,
this.projectCommission(value),
this.contributorCommission(value)
);
if(invoiced != null) {
issue.comments().post(
String.format(
project.language().reply(
"taskInvoiced.comment"
),
assignee.username()
)
);
if(issue.assignee() != null) {
issue.unassign(issue.assignee());
}
try {
final Issue issue = task.issue();
if (issue.isClosed()) {
LOG.debug(
"Task #" + issue.issueId() + " successfully"
+ " invoiced and taken out of scope."
"Task #" + issue.issueId()
+ " of Contributor " + assignee.username()
+ " is closed. Invoicing... "
);
}
} else {
final LocalDateTime now = this.dateTimeSupplier.get();
if (now.until(task.deadline(), ChronoUnit.MINUTES) < 0) {
task.resignations()
.register(task, Resignations.Reason.DEADLINE);
task.unassign();
if(issue.assignee() != null) {
issue.unassign(issue.assignee());
final BigDecimal value = task.value();
final InvoicedTask invoiced = task.contract()
.invoices()
.active()
.register(
task,
this.projectCommission(value),
this.contributorCommission(value)
);
if (invoiced != null) {
issue.comments().post(
String.format(
project.language().reply(
"taskInvoiced.comment"
),
assignee.username()
)
);
if (issue.assignee() != null) {
issue.unassign(issue.assignee());
}
LOG.debug(
"Task #" + issue.issueId() + " successfully"
+ " invoiced and taken out of scope."
);
}
issue.comments().post(
String.format(
project.language().reply(
"taskDeadlineMissed.comment"
),
assignee.username(),
task.deadline()
)
);
} else {
final int time = Period.between(
task.assignmentDate().toLocalDate(),
task.deadline().toLocalDate()
).getDays();
final int left = Period.between(
now.toLocalDate(),
task.deadline().toLocalDate()
).getDays();
if (left <= time / 2) {
final LocalDateTime now = this.dateTimeSupplier.get();
final LocalDateTime deadline = task.deadline();
if (now.until(deadline, ChronoUnit.MINUTES) < 0) {
task.resignations()
.register(task, Resignations.Reason.DEADLINE);
task.unassign();
if (issue.assignee() != null) {
issue.unassign(issue.assignee());
}
issue.comments().post(
String.format(
project.language().reply(
"taskDeadlineReminder.comment"
"taskDeadlineMissed.comment"
),
assignee.username(),
task.deadline()
)
);
} else {
final int time = Period.between(
task.assignmentDate().toLocalDate(),
task.deadline().toLocalDate()
).getDays();
final int left = Period.between(
now.toLocalDate(),
task.deadline().toLocalDate()
).getDays();
if (left <= time / 2) {
issue.comments().post(
String.format(
project.language().reply(
"taskDeadlineReminder.comment"
),
assignee.username(),
task.deadline()
)
);
}
}
}
//@checkstyle IllegalCatch (2 lines)
} catch (final RuntimeException ex) {
LOG.error(
"Problem while checking the ASSIGNED Task #"
+ task.issueId() + " of Project "
+ project.repoFullName() + " at " + project.provider()
+ ". Ignoring and moving on.",
ex
);
}
}
}
Expand Down

0 comments on commit 2230f93

Please sign in to comment.