public Calculation fetchCalculation()

in src/main/java/com/github/reviewassistant/reviewassistant/AdviceCacheImpl.java [112:146]


  public Calculation fetchCalculation(RevisionResource resource) {
    String revision = resource.getPatchSet().commitId().name();
    try {
      Calculation calc =
          cache.get(
              revision,
              () -> {
                try {
                  ChangeApi cApi = gApi.changes().id(resource.getChange().getChangeId());
                  ChangeInfo info = cApi.get();
                  double reviewTimeModifier =
                      cfg.getProjectPluginConfigWithInheritance(
                              resource.getChange().getProject(), pluginName)
                          .getInt("time", "reviewTimeModifier", 100);
                  Calculation c = ReviewAssistant.calculate(info, reviewTimeModifier / 100);
                  return c;
                } catch (RestApiException e) {
                  log.error(
                      "Could not get ChangeInfo for change {}", resource.getChange().getChangeId());
                  throw e;
                } catch (NoSuchProjectException e) {
                  log.error(e.getMessage(), e);
                  throw e;
                }
              });
      if (calc == null || calc.totalReviewTime == 0) {
        log.debug("Corrupt or missing calculation for {}", revision);
        cache.invalidate(revision);
        return null;
      }
      return calc;
    } catch (Exception e) {
      return null;
    }
  }