MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / getTopPages

Function getTopPages

packages/db/src/services/event.service.ts:805–830  ·  view source on GitHub ↗
({
  projectId,
  cursor,
  take,
  search,
}: {
  projectId: string;
  cursor?: number;
  take: number;
  search?: string;
})

Source from the content-addressed store, hash-verified

803}
804
805export async function getTopPages({
806 projectId,
807 cursor,
808 take,
809 search,
810}: {
811 projectId: string;
812 cursor?: number;
813 take: number;
814 search?: string;
815}) {
816 const res = await chQuery<IServicePage>(`
817 SELECT path, count(*) as count, project_id, first_value(created_at) as first_seen, last_value(properties['__title']) as title, origin
818 FROM ${TABLE_NAMES.events}
819 WHERE name = 'screen_view'
820 AND project_id = ${sqlstring.escape(projectId)}
821 AND created_at > now() - INTERVAL 30 DAY
822 ${search ? `AND path ILIKE '%${search}%'` : ''}
823 GROUP BY path, project_id, origin
824 ORDER BY count desc
825 LIMIT ${take}
826 OFFSET ${Math.max(0, (cursor ?? 0) * take)}
827 `);
828
829 return res;
830}
831
832export interface IEventServiceGetList {
833 projectId: string;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected