Skip to content

Commit

Permalink
Now passing single reportId instead of array for GET reports/results
Browse files Browse the repository at this point in the history
  • Loading branch information
heythisischris committed Jun 29, 2024
1 parent 2eddc9a commit f9bbfc5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/routes/getReports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { graphqlQuery } from '#src/utils';
export const getReports = async ({ request, reply }) => {
const response = (await graphqlQuery({
query: `query($first: Int, $offset: Int){
reports: reportsConnection(first: $first, offset: $offset, ${(request.query.reportIds) ? `filter: { id: {in: [
${request.query.reportIds.split(',').map(obj => `"${obj}"`).join()}
]}}` : ''}
reports: reportsConnection(first: $first, offset: $offset, ${(request.query.reportId) ? `filter: { id: {eq: "${request.query.reportId}"}}` : ''}
) {
nodes {
id
Expand Down
3 changes: 1 addition & 2 deletions src/routes/getResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ export const getResults = async ({ request, reply }) => {
Ability to filter by propertyIds, urlIds, nodeIds, nodeUpdateIds, messageIds, and tagIds
Messages, Tags, Properties, Pages are sorted by properties related to the most nodes w/ nodeEqualified set to false (most to least)
*/
console.log(request.query);
await pgClient.connect();
const reports = (await pgClient.query(`SELECT "id", "name", "filters" FROM "reports" WHERE "id" = ANY($1::uuid[])`, [request.query.reportIds])).rows;
const reports = (await pgClient.query(`SELECT "id", "name", "filters" FROM "reports" WHERE "id" = $1`, [request.query.reportId])).rows;
console.log(JSON.stringify(reports));
await pgClient.clean();
const response = await graphqlQuery({
Expand Down

0 comments on commit f9bbfc5

Please sign in to comment.