-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datapoint count and truncate data #294
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,26 @@ import { db } from '@/lib/db/drizzle'; | |
import { datasetDatapoints } from '@/lib/db/migrations/schema'; | ||
import { fetcher } from '@/lib/utils'; | ||
|
||
export async function GET( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding authentication and authorization checks in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handled in middleware |
||
req: Request, | ||
{ | ||
params | ||
}: { params: { projectId: string; datasetId: string; datapointId: string } } | ||
) { | ||
const datapoint = await db.query.datasetDatapoints.findFirst({ | ||
where: and( | ||
eq(datasetDatapoints.id, params.datapointId), | ||
eq(datasetDatapoints.datasetId, params.datasetId) | ||
) | ||
}); | ||
|
||
if (!datapoint) { | ||
return new Response('Datapoint not found', { status: 404 }); | ||
} | ||
|
||
return new Response(JSON.stringify(datapoint), { status: 200 }); | ||
} | ||
|
||
export async function POST( | ||
req: Request, | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
SUBSTRING
function in SQL should start from index 1, not 0. Update the query toSUBSTRING(data::text, 1, 100)
andSUBSTRING(target::text, 1, 100)
to correctly truncate the data and target fields.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine in postgres