fix filter

This commit is contained in:
2025-04-02 20:05:33 +08:00
parent 8054b0235d
commit a6f7172ec4
6 changed files with 106 additions and 61 deletions

View File

@@ -181,6 +181,9 @@ export async function getTimeSeriesData(params: {
endTime: string;
linkId?: string;
granularity: 'hour' | 'day' | 'week' | 'month';
teamIds?: string[];
projectIds?: string[];
tagIds?: string[];
}): Promise<TimeSeriesData[]> {
const filter = buildFilter(params);
@@ -213,9 +216,12 @@ export async function getGeoAnalytics(params: {
endTime?: string;
linkId?: string;
groupBy?: 'country' | 'city';
teamIds?: string[];
projectIds?: string[];
tagIds?: string[];
}): Promise<GeoData[]> {
const filter = buildFilter(params);
const groupByField = 'ip_address'; // 暂时按 IP 地址分组
const groupByField = params.groupBy === 'city' ? 'city' : 'country';
const query = `
SELECT
@@ -228,7 +234,7 @@ export async function getGeoAnalytics(params: {
GROUP BY ${groupByField}
HAVING location != ''
ORDER BY visits DESC
LIMIT 10
LIMIT 20
`;
return executeQuery<GeoData>(query);