Skip to content

Commit

Permalink
rename query.form_data to query.params
Browse files Browse the repository at this point in the history
  • Loading branch information
eriktaubeneck committed Jun 8, 2024
1 parent 339699c commit dda986e
Show file tree
Hide file tree
Showing 4 changed files with 229 additions and 27 deletions.
6 changes: 3 additions & 3 deletions server/app/query/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ export default function Page() {
) => {
event.preventDefault();
try {
const formData = new FormData(event.currentTarget);
const query: Query = await createNewQuery(formData, queryType);
const params = new FormData(event.currentTarget);
const query: Query = await createNewQuery(params, queryType);

setQueryId(query.displayId);

// Send a POST request to start the process
for (const remoteServer of Object.values(remoteServers)) {
const response = await fetch(remoteServer.startURL(query.uuid), {
method: "POST",
body: formData,
body: params,
});
const _data = await response.json();
}
Expand Down
10 changes: 5 additions & 5 deletions server/data/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface Query {
displayId: string;
type: QueryType;
status: Status;
formData: Json;
params: Json;
createdAt: string;
startedAt: string | null;
endedAt: string | null;
Expand All @@ -27,7 +27,7 @@ function processQueryData(data: QueryRow): Query {
displayId: data.display_id,
type: data.type as QueryType,
status: data.status as Status,
formData: data.form_data,
params: data.params,
createdAt: data.created_at,
startedAt: data.started_at,
endedAt: data.ended_at,
Expand Down Expand Up @@ -69,10 +69,10 @@ export async function getQuery(displayId: string): Promise<Query> {
}

export async function createNewQuery(
formData: FormData,
params: FormData,
queryType: QueryType,
): Promise<Query> {
const json = JSON.stringify(Object.fromEntries(formData));
const json = JSON.stringify(Object.fromEntries(params));
const cookieStore = cookies();

const supabase = createServerClient<Database>(
Expand Down Expand Up @@ -104,7 +104,7 @@ export async function createNewQuery(
display_id: uniqueDisplayId,
status: "QUEUED",
type: queryType,
form_data: json,
params: json,
})
.select()
.returns<QueryRow>()
Expand Down
Loading

0 comments on commit dda986e

Please sign in to comment.