Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Fix users page (sorting) (#114)

Andrii Andrushchyshynf4ca270abe2d
diff --git a/client/src/app/[site]/users/page.tsx b/client/src/app/[site]/users/page.tsx
index 1e907a256..72d0e6e97 100644
--- a/client/src/app/[site]/users/page.tsx
+++ b/client/src/app/[site]/users/page.tsx
@@ -50,7 +50,7 @@ const SortHeader = ({ column, children }: any) => {
return (
<Button
variant="ghost"
- onClick={() => column.toggleSorting(isSorted === "asc")}
+ onClick={() => column.toggleSorting(isSorted ? isSorted === "asc" : true)}
className="p-0 hover:bg-transparent"
>
{children}
diff --git a/server/src/api/analytics/getUsers.ts b/server/src/api/analytics/getUsers.ts
index a6aec13f7..b12b2cd99 100644
--- a/server/src/api/analytics/getUsers.ts
+++ b/server/src/api/analytics/getUsers.ts
@@ -110,7 +110,7 @@ WITH AggregatedUsers AS (
SELECT *
FROM AggregatedUsers
WHERE 1 = 1 ${filterStatement}
-ORDER BY {sortBy:String} ${actualSortOrder}
+ORDER BY ${actualSortBy} ${actualSortOrder}
LIMIT {limit:Int32} OFFSET {offset:Int32}
`;
@@ -135,8 +135,6 @@ WHERE
siteId: Number(site),
limit: pageSizeNum,
offset,
- sortBy: actualSortBy,
- sortOrder: actualSortOrder,
},
}),
clickhouse.query({