Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

(fix) Minute timebucket (#344)

Andrii Romasiun0ce3852ef2a0
diff --git a/app/modals/Forecast.tsx b/app/modals/Forecast.tsx
index 88eef9aa6..d56d25290 100644
--- a/app/modals/Forecast.tsx
+++ b/app/modals/Forecast.tsx
@@ -8,7 +8,7 @@ import Input from 'ui/Input'
import { FORECAST_MAX_MAPPING } from 'redux/constants'
import _toString from 'lodash/toString'
-const DEFAULT_PERIOD = 3
+const DEFAULT_PERIOD = '3'
const Forecast = ({
onClose, onSubmit, isOpened, activeTB, tb,
@@ -22,7 +22,7 @@ const Forecast = ({
const { t }: {
t: (key: string, options?: { [key: string]: string | number }) => string,
} = useTranslation('common')
- const [period, setPeriod] = useState<string | number>(DEFAULT_PERIOD)
+ const [period, setPeriod] = useState<string>(DEFAULT_PERIOD)
const [error, setError] = useState<string | null>(null)
const handleInput = (e: React.ChangeEvent<HTMLInputElement>) => {
@@ -79,7 +79,7 @@ const Forecast = ({
frequency: activeTB,
})}
value={period}
- placeholder={`${DEFAULT_PERIOD}`}
+ placeholder={DEFAULT_PERIOD}
className='mt-4'
onChange={handleInput}
error={error}
diff --git a/app/redux/constants/index.ts b/app/redux/constants/index.ts
index 10378d6a3..f61cc5698 100644
--- a/app/redux/constants/index.ts
+++ b/app/redux/constants/index.ts
@@ -31,6 +31,10 @@ export const tbPeriodPairs = (t: Function, tbs?: string[] | null, dates?: Date[]
dropdownLabel?: string
isCustomDate?: boolean
}[] => [{
+ label: t('project.thisHour'),
+ period: '1h',
+ tbs: ['minute'],
+}, {
label: t('project.today'),
period: 'today',
tbs: ['hour'],
@@ -83,7 +87,7 @@ export const tbPeriodPairs = (t: Function, tbs?: string[] | null, dates?: Date[]
tbs: tbs || ['custom'],
}]
-export const filtersPeriodPairs = ['1d', '7d', '4w', '3M', '12M', 'custom', 'compare']
+export const filtersPeriodPairs = ['1h', '1d', '7d', '4w', '3M', '12M', 'custom', 'compare']
export const tbPeriodPairsCompare = (t: Function, dates?: Date[]): {
label: string
@@ -127,6 +131,7 @@ export const timeBucketToDays: {
lt: number
tb: string[]
}[] = [
+ // { lt: 0, tb: ['minute'] }, // 1 hour
{ lt: 1, tb: ['hour'] }, // 1 days
{ lt: 7, tb: ['hour', 'day'] }, // 7 days
{ lt: 28, tb: ['day'] }, // 4 weeks
@@ -135,6 +140,7 @@ export const timeBucketToDays: {
]
export const tbsFormatMapper: IStringObject = {
+ minute: '%I:%M %p',
hour: '%I %p',
day: '%d %b',
month: '%b %Y',
@@ -142,6 +148,7 @@ export const tbsFormatMapper: IStringObject = {
}
export const tbsFormatMapperTooltip: IStringObject = {
+ minute: '%I:%M %p',
hour: '%d %b %I %p',
day: '%d %b',
month: '%b %Y',
@@ -149,6 +156,7 @@ export const tbsFormatMapperTooltip: IStringObject = {
}
export const tbsFormatMapperTooltip24h: IStringObject = {
+ minute: '%H:%M',
hour: '%d %b %H:%M',
day: '%d %b',
month: '%b %Y',
@@ -156,6 +164,7 @@ export const tbsFormatMapperTooltip24h: IStringObject = {
}
export const tbsFormatMapper24h: IStringObject = {
+ minute: '%H:%M',
hour: '%H:%M',
day: '%d %b',
month: '%b %Y',
diff --git a/public/locales/en.json b/public/locales/en.json
index 1e3ca9f36..c0469199c 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -590,7 +590,7 @@
"unique": "Unique visitors",
"results": "Results",
"total": "Total page views",
- "thishour": "This hour",
+ "thisHour": "This hour",
"all": "All time",
"today": "Today",
"yesterday": "Yesterday",
@@ -599,6 +599,7 @@
"lastXWeeks": "Last {{amount}} weeks",
"lastXMonths": "Last {{amount}} months",
"custom": "Custom date",
+ "minute": "Minute",
"hour": "Hour",
"day": "Day",
"week": "Week",