Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nengyuanzhang committed Jul 23, 2024
2 parents 050565c + a9bbf94 commit e6c9482
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 0 deletions.
33 changes: 33 additions & 0 deletions myems-web/src/components/MyEMS/Tenant/TenantCarbon.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,39 @@ const TenantCarbon = ({ setRedirect, setRedirectUrl, t }) => {
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);

const dateDifferenceInSeconds = moment(DateRange[1]).valueOf() / 1000 - moment(DateRange[0]).valueOf() / 1000;
if (periodType === 'hourly') {
if (dateDifferenceInSeconds > 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds > 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
} else if (dateDifferenceInSeconds > 30 * 24 * 60 * 60) {
// more than 30 days
setPeriodType('daily');
document.getElementById('periodType').value = 'daily';
}
} else if (periodType === 'daily') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds >= 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
}
} else if (periodType === 'monthly') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
}
}
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([
moment(DateRange[0])
Expand Down
33 changes: 33 additions & 0 deletions myems-web/src/components/MyEMS/Tenant/TenantCost.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,39 @@ const TenantCost = ({ setRedirect, setRedirectUrl, t }) => {
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);

const dateDifferenceInSeconds = moment(DateRange[1]).valueOf() / 1000 - moment(DateRange[0]).valueOf() / 1000;
if (periodType === 'hourly') {
if (dateDifferenceInSeconds > 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds > 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
} else if (dateDifferenceInSeconds > 30 * 24 * 60 * 60) {
// more than 30 days
setPeriodType('daily');
document.getElementById('periodType').value = 'daily';
}
} else if (periodType === 'daily') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds >= 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
}
} else if (periodType === 'monthly') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
}
}
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([
moment(DateRange[0])
Expand Down
33 changes: 33 additions & 0 deletions myems-web/src/components/MyEMS/Tenant/TenantEnergyCategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,39 @@ const TenantEnergyCategory = ({ setRedirect, setRedirectUrl, t }) => {
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);

const dateDifferenceInSeconds = moment(DateRange[1]).valueOf() / 1000 - moment(DateRange[0]).valueOf() / 1000;
if (periodType === 'hourly') {
if (dateDifferenceInSeconds > 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds > 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
} else if (dateDifferenceInSeconds > 30 * 24 * 60 * 60) {
// more than 30 days
setPeriodType('daily');
document.getElementById('periodType').value = 'daily';
}
} else if (periodType === 'daily') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds >= 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
}
} else if (periodType === 'monthly') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
}
}
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([
moment(DateRange[0])
Expand Down
33 changes: 33 additions & 0 deletions myems-web/src/components/MyEMS/Tenant/TenantEnergyItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,39 @@ const TenantEnergyItem = ({ setRedirect, setRedirectUrl, t }) => {
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);

const dateDifferenceInSeconds = moment(DateRange[1]).valueOf() / 1000 - moment(DateRange[0]).valueOf() / 1000;
if (periodType === 'hourly') {
if (dateDifferenceInSeconds > 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds > 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
} else if (dateDifferenceInSeconds > 30 * 24 * 60 * 60) {
// more than 30 days
setPeriodType('daily');
document.getElementById('periodType').value = 'daily';
}
} else if (periodType === 'daily') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds >= 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
}
} else if (periodType === 'monthly') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
}
}
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([
moment(DateRange[0])
Expand Down
33 changes: 33 additions & 0 deletions myems-web/src/components/MyEMS/Tenant/TenantLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,39 @@ const TenantLoad = ({ setRedirect, setRedirectUrl, t }) => {
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);

const dateDifferenceInSeconds = moment(DateRange[1]).valueOf() / 1000 - moment(DateRange[0]).valueOf() / 1000;
if (periodType === 'hourly') {
if (dateDifferenceInSeconds > 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds > 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
} else if (dateDifferenceInSeconds > 30 * 24 * 60 * 60) {
// more than 30 days
setPeriodType('daily');
document.getElementById('periodType').value = 'daily';
}
} else if (periodType === 'daily') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds >= 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
}
} else if (periodType === 'monthly') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
}
}
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([
moment(DateRange[0])
Expand Down
33 changes: 33 additions & 0 deletions myems-web/src/components/MyEMS/Tenant/TenantPlan.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,39 @@ const TenantPlan = ({ setRedirect, setRedirectUrl, t }) => {
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);

const dateDifferenceInSeconds = moment(DateRange[1]).valueOf() / 1000 - moment(DateRange[0]).valueOf() / 1000;
if (periodType === 'hourly') {
if (dateDifferenceInSeconds > 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds > 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
} else if (dateDifferenceInSeconds > 30 * 24 * 60 * 60) {
// more than 30 days
setPeriodType('daily');
document.getElementById('periodType').value = 'daily';
}
} else if (periodType === 'daily') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds >= 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
}
} else if (periodType === 'monthly') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
}
}
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([
moment(DateRange[0])
Expand Down
33 changes: 33 additions & 0 deletions myems-web/src/components/MyEMS/Tenant/TenantSaving.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,39 @@ const TenantSaving = ({ setRedirect, setRedirectUrl, t }) => {
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);

const dateDifferenceInSeconds = moment(DateRange[1]).valueOf() / 1000 - moment(DateRange[0]).valueOf() / 1000;
if (periodType === 'hourly') {
if (dateDifferenceInSeconds > 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds > 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
} else if (dateDifferenceInSeconds > 30 * 24 * 60 * 60) {
// more than 30 days
setPeriodType('daily');
document.getElementById('periodType').value = 'daily';
}
} else if (periodType === 'daily') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds >= 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
}
} else if (periodType === 'monthly') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
}
}
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([
moment(DateRange[0])
Expand Down
33 changes: 33 additions & 0 deletions myems-web/src/components/MyEMS/Tenant/TenantStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,39 @@ const TenantStatistics = ({ setRedirect, setRedirectUrl, t }) => {
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);

const dateDifferenceInSeconds = moment(DateRange[1]).valueOf() / 1000 - moment(DateRange[0]).valueOf() / 1000;
if (periodType === 'hourly') {
if (dateDifferenceInSeconds > 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds > 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
} else if (dateDifferenceInSeconds > 30 * 24 * 60 * 60) {
// more than 30 days
setPeriodType('daily');
document.getElementById('periodType').value = 'daily';
}
} else if (periodType === 'daily') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds >= 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
}
} else if (periodType === 'monthly') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
}
}
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([
moment(DateRange[0])
Expand Down

0 comments on commit e6c9482

Please sign in to comment.