Domain validation. Filter domain from referrers.

This commit is contained in:
Mike Cao 2020-08-28 21:34:20 -07:00
parent a9765c7ea7
commit 5a4cde854a
13 changed files with 51 additions and 23 deletions

View file

@ -347,9 +347,11 @@ export function getPageviews(
return Promise.resolve([]);
}
export function getRankings(website_id, start_at, end_at, type, table) {
export function getRankings(website_id, start_at, end_at, type, table, domain) {
const db = getDatabase();
const filter = domain ? `and ${type} not like '%${domain}%'` : '';
if (db === POSTGRESQL) {
return prisma.$queryRaw(
`
@ -357,6 +359,7 @@ export function getRankings(website_id, start_at, end_at, type, table) {
from ${table}
where website_id=$1
and created_at between $2 and $3
${filter}
group by 1
order by 2 desc
`,
@ -373,6 +376,7 @@ export function getRankings(website_id, start_at, end_at, type, table) {
from ${table}
where website_id=?
and created_at between ? and ?
${filter}
group by 1
order by 2 desc
`,