Skip to content

Commit

Permalink
web/satellite/v2: truncate date params to hours for /daily-usage and …
Browse files Browse the repository at this point in the history
…/usage-report endpoints

Truncate date params to hours only so that requests don't change within one hour.

Issue:
storj/storj-private#567

Change-Id: Ibea5edf640083323652dc5ee42b2e9b95b98a7f3
  • Loading branch information
VitaliiShpital authored and Storj Robot committed Jan 23, 2024
1 parent 84fd22d commit 1d8e42c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ const customRange = ref<Date[]>([]);
function setPastMonth(): void {
const now = new Date();
since.value = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth() - 1, now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes()));
before.value = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes()));
since.value = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth() - 1, now.getUTCDate(), now.getUTCHours(), 0, 0, 0));
before.value = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), 0, 0, 0));
option.value = Options.Month;
}
Expand All @@ -129,8 +129,8 @@ function setPastMonth(): void {
function setPastYear(): void {
const now = new Date();
since.value = new Date(Date.UTC(now.getUTCFullYear() - 1, now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes()));
before.value = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes()));
since.value = new Date(Date.UTC(now.getUTCFullYear() - 1, now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), 0, 0, 0));
before.value = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), 0, 0, 0));
option.value = Options.Year;
}
Expand Down Expand Up @@ -175,8 +175,8 @@ watch(customRange, () => {
[start, end] = [end, start];
}
since.value = new Date(Date.UTC(start.getFullYear(), start.getMonth(), start.getDate(), start.getHours(), start.getMinutes()));
before.value = new Date(Date.UTC(end.getFullYear(), end.getMonth(), end.getDate(), end.getHours(), end.getMinutes()));
since.value = new Date(Date.UTC(start.getFullYear(), start.getMonth(), start.getDate(), start.getHours(), 0, 0, 0));
before.value = new Date(Date.UTC(end.getFullYear(), end.getMonth(), end.getDate(), 23, 59, 59, 999));
});
watch(option, () => {
Expand Down
4 changes: 4 additions & 0 deletions web/satellite/vuetify-poc/src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,10 @@ onMounted(async (): Promise<void> => {
const past = new Date();
past.setDate(past.getDate() - 7);
// Truncate dates to hours only.
now.setMinutes(0, 0, 0);
past.setMinutes(0, 0, 0);
let promises: Promise<void | ProjectMembersPage | AccessGrantsPage | AccountBalance | CreditCard[]>[] = [
projectsStore.getDailyProjectData({ since: past, before: now }),
projectsStore.getProjectLimits(projectID),
Expand Down

0 comments on commit 1d8e42c

Please sign in to comment.