Skip to content

Commit

Permalink
wip: 30D/30m
Browse files Browse the repository at this point in the history
  • Loading branch information
chienleng committed Sep 7, 2023
1 parent b69973d commit 4d4b66c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
8 changes: 4 additions & 4 deletions components/Energy/DataOptionsBarTimeOfDay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ export default {
label: '7D',
value: '7D'
},
// {
// label: '28D',
// value: '28D'
// }
{
label: '30D',
value: '30D'
}
],
intervals: [
{
Expand Down
2 changes: 1 addition & 1 deletion constants/ranges.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const RANGE_INTERVALS = {}
RANGE_INTERVALS[RANGE_1D] = [INTERVALS.INTERVAL_5MIN, INTERVALS.INTERVAL_30MIN]
RANGE_INTERVALS[RANGE_3D] = [INTERVALS.INTERVAL_5MIN, INTERVALS.INTERVAL_30MIN]
RANGE_INTERVALS[RANGE_7D] = [INTERVALS.INTERVAL_5MIN, INTERVALS.INTERVAL_30MIN]
RANGE_INTERVALS[RANGE_30D] = [INTERVALS.INTERVAL_DAY]
RANGE_INTERVALS[RANGE_30D] = [INTERVALS.INTERVAL_30MIN, INTERVALS.INTERVAL_DAY]
RANGE_INTERVALS[RANGE_1Y] = [
INTERVALS.INTERVAL_DAY,
INTERVALS.INTERVAL_WEEK,
Expand Down
16 changes: 14 additions & 2 deletions pages/energy/_region/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/>

<div
v-if="range === '3D' || range === '7D'"
v-if="range === '3D' || range === '7D' || range === '30D'"
class="field has-addons"
style="margin-bottom: 0;">
<button
Expand Down Expand Up @@ -313,7 +313,19 @@ export default {
interval,
filterPeriod: this.filterPeriod
})
this.doUpdateDatasetByInterval({ range: this.range, interval })
console.log('interval change', interval, this.range)
if (this.range === '30D') {
this.doGetRegionDataByRangeInterval({
region: this.regionId,
range: this.range,
interval,
period: this.filterPeriod,
groupName: this.fuelTechGroupName
})
} else {
this.doUpdateDatasetByInterval({ range: this.range, interval })
}
},
filteredDates(dates) {
this.doUpdateXTicks({
Expand Down
13 changes: 9 additions & 4 deletions services/Data.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import subDays from 'date-fns/subDays'
import subYears from 'date-fns/subYears'

import * as rangesJs from '~/constants/ranges.js'
import { INTERVAL_30MIN } from '~/constants/interval-filters.js'

function getYearPaths(prepend, regionId, oneYearAgo) {
const today = new Date()
Expand All @@ -25,7 +26,7 @@ function getYearPaths(prepend, regionId, oneYearAgo) {
}

export default {
getEnergyUrls(region, range) {
getEnergyUrls(region, range, interval) {
const prepend =
region === 'wem' || region === 'nem' || region === 'au' ? '' : '/NEM'
const regionId = region.toUpperCase()
Expand All @@ -40,9 +41,13 @@ export default {
break

case rangesJs.RANGE_30D:
const thirtyDaysAgo = subDays(new Date(), 30)
oneYearAgo = thirtyDaysAgo.getFullYear()
urls = getYearPaths(prepend, regionId, oneYearAgo)
if (interval === INTERVAL_30MIN) {
urls.push(`v3/stats/au${prepend}/${regionId}/power/30d.json`)
} else {
const thirtyDaysAgo = subDays(new Date(), 30)
oneYearAgo = thirtyDaysAgo.getFullYear()
urls = getYearPaths(prepend, regionId, oneYearAgo)
}
break

case rangesJs.RANGE_1Y:
Expand Down
2 changes: 1 addition & 1 deletion store/regionEnergy.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ export const actions = {

if (isValidRegion(region) && range !== '' && interval !== '') {
const displayTz = rootGetters.displayTimeZone
const urls = Data.getEnergyUrls(region, range)
const urls = Data.getEnergyUrls(region, range, interval)
currentRegion = region
commit('ready', false)
commit('isFetching', true)
Expand Down

0 comments on commit 4d4b66c

Please sign in to comment.