Skip to content

Commit

Permalink
Merge branch 'bob/que-86-refactor-query-related-table-creation' of ht…
Browse files Browse the repository at this point in the history
…tps://github.com/CDCgov/dibbs-query-connector into bob/que-86-refactor-query-related-table-creation
  • Loading branch information
fzhao99 committed Dec 12, 2024
2 parents 84b6ac1 + 7586312 commit c04ad17
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
20 changes: 2 additions & 18 deletions query-connector/src/app/database-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,28 +741,12 @@ export async function getCustomQueries(): Promise<CustomUserQuery[]> {
* @returns A success or error response indicating the result.
*/
export const deleteQueryById = async (queryId: string) => {
// TODO: should be able to simplified when it is just deleting query table
const deleteQuerySql1 = `
DELETE FROM query_included_concepts
WHERE query_by_valueset_id IN (
SELECT id FROM query_to_valueset WHERE query_id = $1
);
`;
const deleteQuerySql2 = `
DELETE FROM query_to_valueset WHERE query_id = $1;
`;
const deleteQuerySql3 = `
const deleteQuery = `
DELETE FROM query WHERE id = $1;
`;

try {
await dbClient.query("BEGIN");

// Execute deletion queries in the correct order
await dbClient.query(deleteQuerySql1, [queryId]);
await dbClient.query(deleteQuerySql2, [queryId]);
await dbClient.query(deleteQuerySql3, [queryId]);

await dbClient.query(deleteQuery, [queryId]);
await dbClient.query("COMMIT");
return { success: true };
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ export const UserQueriesDisplay: React.FC<UserQueriesDisplayProps> = ({
{queries.map((query, index) => (
<tr key={index} className="tableRowWithHover">
<td title={query.query_name}>{query.query_name}</td>
<td title={query.query_name}>{query.query_name}</td>
{/* TODO: Use conditions_list once available */}
<td title={query.conditions_list}>{query.conditions_list}</td>
<td>
<div className="table-cell-buttons">
<Button
Expand Down

0 comments on commit c04ad17

Please sign in to comment.