Skip to content

Commit

Permalink
Usage metrics now go back at least 3 years
Browse files Browse the repository at this point in the history
  • Loading branch information
jfkonecn committed Aug 1, 2024
1 parent 5da2253 commit 70d9e8d
Showing 1 changed file with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.mskcc.cbio.oncokb.config.Constants;
import org.mskcc.cbio.oncokb.domain.User;
import org.mskcc.cbio.oncokb.domain.enumeration.FileExtension;
Expand Down Expand Up @@ -522,7 +521,6 @@ private void addUsers(String[] userNames) throws Exception {

for (int yearIndex = 0; yearIndex < 4; yearIndex++) {
int year = currentYear - yearIndex;
Boolean isThisYear = yearIndex == 0;

DateTimeFormatter dayFormatter = DateTimeFormatter.ofPattern(
"yyyy-MM-dd"
Expand Down Expand Up @@ -584,33 +582,33 @@ private void addUsers(String[] userNames) throws Exception {
dayKey
);

boolean isAfterOrEqualToPast12Months = date.isAfter(
today.minusMonths(11).withDayOfMonth(1).minusDays(1)
boolean isAfterOrEqualToPast3FullYearAndYearToDate = date.isAfter(
today.minusYears(3).withDayOfYear(1).minusDays(1)
);
boolean isBeforeOrEqualToToday = date.isBefore(
today.plusMonths(1).withDayOfMonth(1)
today.plusDays(1)
);

// update expected response for monthly resource summary
if (isThisYear) {
Boolean shouldBeInResponse =
isAfterOrEqualToPast3FullYearAndYearToDate &&
isBeforeOrEqualToToday;

if (shouldBeInResponse) {
// update expected response for monthly resource summary
updateResourceSummaryExpectedResponse(
value,
oncokbEndpoint,
monthKey
);
}

// update expected response for user usage endpoint
if (isThisYear) {
// update expected response for user usage endpoint
safeAddNestedValueInFilesObject(
value,
usageUserEndpoint,
"summary",
"year",
oncokbEndpoint
);
}
if (isAfterOrEqualToPast12Months && isBeforeOrEqualToToday) {

safeAddNestedValueInFilesObject(
value,
usageUserEndpoint,
Expand All @@ -627,19 +625,15 @@ private void addUsers(String[] userNames) throws Exception {
dayKey,
oncokbEndpoint
);
}

if (isThisYear) {
updateSpecificEndpointUserUsageExpectedResponse(
value,
user,
oncokbEndpoint,
monthKey
);
}

// update user endpoint usage endpoint
if (isAfterOrEqualToPast12Months && isBeforeOrEqualToToday) {
// update user endpoint usage endpoint
for (String usageSummaryEndpoint : userUsageSummaryEndpoints) {
safeAddNestedValueInFilesObject(
value,
Expand All @@ -657,9 +651,7 @@ private void addUsers(String[] userNames) throws Exception {
monthKey
);
}
}

if (isThisYear) {
userResourceUsage.put(
oncokbEndpoint,
userResourceUsage.get(oncokbEndpoint) + value
Expand Down

0 comments on commit 70d9e8d

Please sign in to comment.