feat: analytics header overview and legend feat: data selectors feat: graph axis and introductory stale data feat: change graph tick labeling feat: color formatting feat: day and month separation in graph grid refactor: move graph logic to its own file chore: create dummy transaction factory feat: make the analytics overview dynamic with data feat: apply timezone to the analytics screen fix: multiple bug fixes fix: graph txs colors fix: graph no data scenario feat: remove placeholder icons fix: used currencies on filtered data fix: remove timezone object formatting fix: forex rates on transaction data fix: styles fix: growth percentage margin refactor: pull up variables fix: clean up code feat: add transparent areas for mouse event purposes fix: replace DateTime with Date fix: small fixes to graph area intervals fix: graph rectangle location fix: d3 onClick event in dot graph chore: move graph popover component to components folder feat: memo dot graph to avoid expensive rerendering refactor: separate Graph component for future refactoring purposes refactor: restructure Graph related components fix: graph memoizing feat: top machines stacked bar graph refactor: further analytics refactor fix: small fixes on top machines graph fix: top machines stacked bar grapy y-axis scaling fix: small fixes on the stacked bar graph feat: add top machines header fix: bar drawing fix: transaction grouping per day of week refactor: general code cleaning up feat: mouseover events fix: transaction filtering on cross-day hour intervals fix: top machines graph edge case fix: NaN instances on graph drawing fix: tooltip date presentation fix: rearrange files for easier understanding fix: tooltip date interval fix: multiple small fixes fix: remove unnecessary arguments fix: add second group of hoverable rectangles
89 lines
2.3 KiB
JavaScript
89 lines
2.3 KiB
JavaScript
import moment from 'moment'
|
|
import * as R from 'ramda'
|
|
|
|
const getPossibleUTCDSTPairs = timezones =>
|
|
R.map(
|
|
it => ({
|
|
utcOffset: it.utcOffset,
|
|
dstOffset: it.dstOffset,
|
|
utcOffsetStr: it.utcOffsetStr,
|
|
dstOffsetStr: it.dstOffsetStr
|
|
}),
|
|
R.uniqBy(
|
|
it => [it.utcOffset, it.dstOffset, it.utcOffsetStr, it.dstOffsetStr],
|
|
timezones
|
|
)
|
|
)
|
|
|
|
const getFormattedTimezones = timezones =>
|
|
R.sort(
|
|
R.ascend(R.prop('utcOffset')),
|
|
R.map(
|
|
it => ({
|
|
utcOffset: it.utcOffset,
|
|
dstOffset: it.dstOffset,
|
|
utcOffsetStr: it.utcOffsetStr,
|
|
dstOffsetStr: it.dstOffsetStr,
|
|
cities: R.map(
|
|
ite => {
|
|
const regionCityPair = R.split('/', ite.name)
|
|
return {
|
|
region: regionCityPair[0],
|
|
city: R.replace(/_/g, ' ', regionCityPair[1]),
|
|
country: ite.country
|
|
}
|
|
},
|
|
R.filter(
|
|
itx =>
|
|
R.eqProps('utcOffset', it, itx) &&
|
|
R.eqProps('dstOffset', it, itx) &&
|
|
!R.isNil(itx.country) &&
|
|
!R.includes('Etc', itx.name) &&
|
|
R.includes('/', itx.name),
|
|
timezones
|
|
)
|
|
)
|
|
}),
|
|
getPossibleUTCDSTPairs(timezones)
|
|
)
|
|
)
|
|
|
|
const getFinalTimezones = timezones => {
|
|
const formattedTimezones = getFormattedTimezones(timezones)
|
|
const nonEmptyTimezones = R.filter(
|
|
it => !R.isEmpty(it.cities),
|
|
formattedTimezones
|
|
)
|
|
const nonDuplicateCities = R.map(
|
|
it => ({
|
|
...it,
|
|
cities: R.uniqBy(R.prop('country'), R.uniqBy(R.prop('city'), it.cities))
|
|
}),
|
|
nonEmptyTimezones
|
|
)
|
|
return nonDuplicateCities
|
|
}
|
|
|
|
const buildLabel = tz => {
|
|
return `(UTC${tz.utcOffsetStr}) ${R.map(it => it.city, tz.cities).join(', ')}`
|
|
}
|
|
|
|
const getTzLabels = timezones =>
|
|
R.map(
|
|
it => ({ label: buildLabel(it), code: `${it.utcOffset}:${it.dstOffset}` }),
|
|
getFinalTimezones(timezones)
|
|
)
|
|
|
|
const formatDate = (date, timezoneCode, format) => {
|
|
const dstOffset = timezoneCode?.split(':')[1] ?? 0
|
|
return moment
|
|
.utc(date)
|
|
.utcOffset(parseInt(dstOffset))
|
|
.format(format)
|
|
}
|
|
|
|
const formatDateNonUtc = (date, format) => {
|
|
return moment(date).format(format)
|
|
}
|
|
|
|
export { getTzLabels, formatDate, formatDateNonUtc }
|