mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
58a67512c9
@ -2,6 +2,7 @@ import useMessages from './useMessages';
|
|||||||
import { BROWSERS } from 'lib/constants';
|
import { BROWSERS } from 'lib/constants';
|
||||||
import useLocale from './useLocale';
|
import useLocale from './useLocale';
|
||||||
import useCountryNames from './useCountryNames';
|
import useCountryNames from './useCountryNames';
|
||||||
|
import regions from 'public/iso-3166-2.json';
|
||||||
|
|
||||||
export function useFormat() {
|
export function useFormat() {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
@ -16,6 +17,10 @@ export function useFormat() {
|
|||||||
return countryNames[value] || value;
|
return countryNames[value] || value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formatRegion = value => {
|
||||||
|
return regions[value] ? regions[value] : value;
|
||||||
|
};
|
||||||
|
|
||||||
const formatDevice = value => {
|
const formatDevice = value => {
|
||||||
return formatMessage(labels[value] || labels.unknown);
|
return formatMessage(labels[value] || labels.unknown);
|
||||||
};
|
};
|
||||||
@ -26,6 +31,8 @@ export function useFormat() {
|
|||||||
return formatBrowser(value);
|
return formatBrowser(value);
|
||||||
case 'country':
|
case 'country':
|
||||||
return formatCountry(value);
|
return formatCountry(value);
|
||||||
|
case 'region':
|
||||||
|
return formatRegion(value);
|
||||||
case 'device':
|
case 'device':
|
||||||
return formatDevice(value);
|
return formatDevice(value);
|
||||||
default:
|
default:
|
||||||
@ -33,7 +40,7 @@ export function useFormat() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return { formatBrowser, formatCountry, formatDevice, formatValue };
|
return { formatBrowser, formatCountry, formatRegion, formatDevice, formatValue };
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useFormat;
|
export default useFormat;
|
||||||
|
@ -112,7 +112,7 @@ async function parseFilters(websiteId: string, filters: QueryFilters = {}, optio
|
|||||||
params: {
|
params: {
|
||||||
...normalizeFilters(filters),
|
...normalizeFilters(filters),
|
||||||
websiteId,
|
websiteId,
|
||||||
startDate: maxDate(filters.startDate, website.resetAt),
|
startDate: maxDate(filters.startDate, new Date(website.resetAt)),
|
||||||
websiteDomain: website.domain,
|
websiteDomain: website.domain,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@ import { badRequest, methodNotAllowed, ok, unauthorized } from 'next-basics';
|
|||||||
import { EVENT_COLUMNS, FILTER_COLUMNS, SESSION_COLUMNS } from 'lib/constants';
|
import { EVENT_COLUMNS, FILTER_COLUMNS, SESSION_COLUMNS } from 'lib/constants';
|
||||||
import { getValues } from 'queries';
|
import { getValues } from 'queries';
|
||||||
|
|
||||||
export interface WebsiteResetRequestQuery {
|
export interface ValuesRequestQuery {
|
||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,10 +17,7 @@ const schema = {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async (
|
export default async (req: NextApiRequestQueryBody<ValuesRequestQuery>, res: NextApiResponse) => {
|
||||||
req: NextApiRequestQueryBody<WebsiteResetRequestQuery>,
|
|
||||||
res: NextApiResponse,
|
|
||||||
) => {
|
|
||||||
await useCors(req, res);
|
await useCors(req, res);
|
||||||
await useAuth(req, res);
|
await useAuth(req, res);
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ export async function resetWebsite(
|
|||||||
}),
|
}),
|
||||||
]).then(async data => {
|
]).then(async data => {
|
||||||
if (cache.enabled) {
|
if (cache.enabled) {
|
||||||
await cache.storeWebsite(data[2]);
|
await cache.storeWebsite(data[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user