Refactored queries.
This commit is contained in:
@@ -52,19 +52,14 @@ export default async (
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const result = await updateReport(
|
||||
{
|
||||
websiteId,
|
||||
userId,
|
||||
type,
|
||||
name,
|
||||
description,
|
||||
parameters: JSON.stringify(parameters),
|
||||
} as any,
|
||||
{
|
||||
id: reportId,
|
||||
},
|
||||
);
|
||||
const result = await updateReport(reportId, {
|
||||
websiteId,
|
||||
userId,
|
||||
type,
|
||||
name,
|
||||
description,
|
||||
parameters: JSON.stringify(parameters),
|
||||
} as any);
|
||||
|
||||
return ok(res, result);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useAuth, useCors } from 'lib/middleware';
|
||||
import { NextApiRequestQueryBody } from 'lib/types';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { createReport, getReports } from 'queries';
|
||||
import { createReport, getWebsiteReports } from 'queries';
|
||||
import { canViewWebsite } from 'lib/auth';
|
||||
import { uuid } from 'lib/crypto';
|
||||
|
||||
@@ -35,7 +35,7 @@ export default async (
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const data = await getReports({ websiteId });
|
||||
const data = await getWebsiteReports(websiteId);
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user