-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update navigation between query building pages (#217)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
fe4696d
commit 38f37e2
Showing
26 changed files
with
436 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { PoolConfig, Pool } from "pg"; | ||
|
||
// Load environment variables from .env and establish a Pool configuration | ||
const dbConfig: PoolConfig = { | ||
connectionString: process.env.DATABASE_URL, | ||
max: 10, // Maximum # of connections in the pool | ||
idleTimeoutMillis: 30000, // A client must sit idle this long before being released | ||
connectionTimeoutMillis: process.env.LOCAL_DB_CLIENT_TIMEOUT | ||
? Number(process.env.LOCAL_DB_CLIENT_TIMEOUT) | ||
: 3000, // Wait this long before timing out when connecting new client | ||
}; | ||
|
||
let cachedDbClient: Pool | null = null; | ||
|
||
/** | ||
* Getter function to retrieve the DB client from a naive cache and create a new one | ||
* if one doesn't exist | ||
* @returns a cached version of the DB client | ||
*/ | ||
export const getDbClient = () => { | ||
if (!cachedDbClient) { | ||
cachedDbClient = new Pool(dbConfig); | ||
} | ||
return cachedDbClient; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use server"; | ||
|
||
import { getDbClient } from "./dbClient"; | ||
import { QueryDetailsResult } from "../queryBuilding/utils"; | ||
const dbClient = getDbClient(); | ||
|
||
/** | ||
* Getter function to grab saved query details from the DB | ||
* @param queryId - Query ID to grab data from the db with | ||
* @returns The query name, data, and conditions list from the query table | ||
*/ | ||
export async function getSavedQueryDetails(queryId: string) { | ||
const id = queryId; | ||
const queryString = ` | ||
select q.query_name, q.id, q.query_data, q.conditions_list | ||
from query q | ||
where q.id = $1; | ||
`; | ||
|
||
try { | ||
const result = await dbClient.query(queryString, [id]); | ||
if (result.rows.length > 0) { | ||
return result.rows as unknown as QueryDetailsResult[]; | ||
} | ||
console.error("No results found for query:", id); | ||
return []; | ||
} catch (error) { | ||
console.error("Error retrieving query", error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.