Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Dec 2, 2024
1 parent 7a91504 commit 4b50aac
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 55 deletions.
12 changes: 7 additions & 5 deletions query-connector/src/app/database-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,23 @@ const dbClient = new Pool(dbConfig);
* or an error if no results can be found.
*/
export const getValueSetsAndConceptsByConditionID = async (id: string) => {
const values = [id]
const values = [id];

try {
const result = await dbClient.query(getValueSetsByConditionId, values);
if (result.rows.length === 0) {
console.error("No results found for Condition", id)
console.error("No results found for Condition", id);
return [];
}
return result.rows;

} catch (error) {
console.error("Error retrieving value sets and concepts for condition", error);
console.error(
"Error retrieving value sets and concepts for condition",
error,
);
throw error;
}
}
};

/**
* Executes a search for a CustomQuery against the query-loaded Postgres
Expand Down
6 changes: 3 additions & 3 deletions query-connector/src/app/query/components/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function HeaderComponent() {
<div
className={classNames(
"usa-nav-container",
styles.headerContentContainer
styles.headerContentContainer,
)}
>
<div className={classNames("display-flex", "flex-align-center")}>
Expand All @@ -76,7 +76,7 @@ export default function HeaderComponent() {
className={classNames(
"margin-left-auto",
"display-flex",
"flex-align-center"
"flex-align-center",
)}
>
{/* TODO: Rework show/hide rules based on actual auth status */}
Expand All @@ -98,7 +98,7 @@ export default function HeaderComponent() {
styles.menuButton,
"usa-accordion__button",
"usa-nav__link",
"usa-current"
"usa-current",
)}
aria-expanded="false"
aria-controls="dropdown-menu"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ export const ConditionColumnDisplay: React.FC<ConditionColumnDisplayProps> = ({
if (searchFilter) {
const filteredDisplay = filterSearchByCategoryAndCondition(
searchFilter,
fetchedConditions
fetchedConditions,
);
setConditionsToDisplay(filteredDisplay);
}
}, [searchFilter]);

async function toggleFetchedConditionSelection(
category: string,
conditionId: string
conditionId: string,
) {
const prevSelected = selectedConditions?.[category]?.[conditionId]?.include;
const prevFetch = structuredClone(fetchedConditions);
Expand Down Expand Up @@ -95,8 +95,7 @@ export const ConditionColumnDisplay: React.FC<ConditionColumnDisplayProps> = ({
category: string,
conditionId: string,
prevFetch: CategoryNameToConditionOptionMap,

) => {
) => {
if (shouldRemove) {
delete selectedConditions[category][conditionId];
// if there are no more entries for a given category, remove the category
Expand All @@ -121,10 +120,10 @@ export const ConditionColumnDisplay: React.FC<ConditionColumnDisplayProps> = ({
};

const columnOneEntries = Object.entries(conditionsToDisplay).filter(
(_, i) => i % 2 === 0
(_, i) => i % 2 === 0,
);
const columnTwoEntries = Object.entries(conditionsToDisplay).filter(
(_, i) => i % 2 === 1
(_, i) => i % 2 === 1,
);

const colsToDisplay = [
Expand Down Expand Up @@ -160,7 +159,7 @@ export const ConditionColumnDisplay: React.FC<ConditionColumnDisplayProps> = ({
handleConditionSelection={handleConditionSelection}
/>
);
}
},
)}
</div>
);
Expand Down
17 changes: 7 additions & 10 deletions query-connector/src/app/queryBuilding/buildFromTemplates/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import Backlink from "@/app/query/components/backLink/Backlink";
import styles from "../buildFromTemplates/buildfromTemplate.module.scss";
import { useRouter } from "next/navigation";
import { Button, Label, TextInput } from "@trussworks/react-uswds";
import { Label, TextInput } from "@trussworks/react-uswds";
import { useEffect, useRef, useState } from "react";
import classNames from "classnames";

import { getConditionsData } from "@/app/database-service";
import {
Expand Down Expand Up @@ -74,7 +73,7 @@ export default function QueryTemplateSelection() {

if (isSubscribed) {
setFetchedConditions(
mapFetchedDataToFrontendStructure(categoryToConditionArrayMap)
mapFetchedDataToFrontendStructure(categoryToConditionArrayMap),
);
}
}
Expand All @@ -85,11 +84,11 @@ export default function QueryTemplateSelection() {
isSubscribed = false;
};
}, [selectedConditions, queryName]);

// ensures the fetchedConditions' checkbox statuses match
// the data in selectedCondtiions
function updateFetchedConditionIncludeStatus(
selectedConditions: CategoryNameToConditionOptionMap
selectedConditions: CategoryNameToConditionOptionMap,
) {
const prevFetch = structuredClone(fetchedConditions);
Object.entries(selectedConditions).map(
Expand All @@ -104,17 +103,17 @@ export default function QueryTemplateSelection() {
};
return setFetchedConditions(prevFetch);
}
}
},
);
}
},
);
}

const validateForm = () => {
if (!queryName || queryName == "") {
focusRef?.current?.focus();
}

return setFormError({
...formError,
...{ queryName: !queryName, selectedConditions: !atLeastOneItemSelected },
Expand Down Expand Up @@ -145,7 +144,6 @@ export default function QueryTemplateSelection() {
} else {
router.push("/queryBuilding");
}

}}
// TODO: tidy this too
label={
Expand Down Expand Up @@ -199,7 +197,6 @@ export default function QueryTemplateSelection() {
valueSetsByCondition={conditionValueSets ?? {}}
/>
)}

</div>
{loading && <LoadingView loading={loading} />}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const ConditionSelection: React.FC<ConditionSelectionProps> = ({

if (isSubscribed) {
setFetchedConditions(
mapFetchedDataToFrontendStructure(categoryToConditionArrayMap)
mapFetchedDataToFrontendStructure(categoryToConditionArrayMap),
);
}
}
Expand Down Expand Up @@ -133,7 +133,7 @@ export const ConditionSelection: React.FC<ConditionSelectionProps> = ({
}

async function handleCreateQueryClick(
event: React.MouseEvent<HTMLButtonElement>
event: React.MouseEvent<HTMLButtonElement>,
) {
event.preventDefault();
setLoading(true);
Expand All @@ -152,7 +152,7 @@ export const ConditionSelection: React.FC<ConditionSelectionProps> = ({
<div
className={classNames(
"bg-gray-5 margin-top-4 ",
styles.conditionTemplateContainer
styles.conditionTemplateContainer,
)}
>
<div className="display-flex flex-justify flex-align-end margin-bottom-3 width-full">
Expand All @@ -176,7 +176,7 @@ export const ConditionSelection: React.FC<ConditionSelectionProps> = ({
id="conditionTemplateSearch"
placeholder="Search conditions"
className={classNames(
"maxw-mobile margin-x-auto margin-top-0 margin-bottom-4"
"maxw-mobile margin-x-auto margin-top-0 margin-bottom-4",
)}
onChange={(e) => {
e.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ function toggleVSConceptCheckboxes(items: ValueSet[], setTo: boolean) {

function renderValueSetAccordions(
conditionId: string,
valueSets: ValueSetsByGroup
valueSets: ValueSetsByGroup,
) {
const handleCheckboxToggle = (
valueSetType: DibbsValueSetType,
conditionId: string
conditionId: string,
) => {
console.log(
valueSets[valueSetType],
`placeholder: deselect all child values (${valueSetType}) for condition ID: ${conditionId}`
`placeholder: deselect all child values (${valueSetType}) for condition ID: ${conditionId}`,
);
};

Expand All @@ -63,7 +63,7 @@ function renderValueSetAccordions(
const ValueSetAccordionItem = Object.values(types).map(
function (valueSetType) {
const valueSetsForType: GroupedValueSet[] = Object.values(
valueSets[valueSetType]
valueSets[valueSetType],
);

return (
Expand Down Expand Up @@ -95,7 +95,7 @@ function renderValueSetAccordions(
/>
</div>
);
}
},
);

return <div>{ValueSetAccordionItem}</div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type SelectionViewAccordionBodyProps = {
valueSets: GroupedValueSet[];
handleCheckboxToggle: (
valueSetType: DibbsValueSetType,
conditionId: string
conditionId: string,
) => void;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type SelectionViewAccordionBodyProps = {
valueSets: GroupedValueSet[] | null;
handleCheckboxToggle: (
valueSetType: DibbsValueSetType,
conditionId: string
conditionId: string,
) => void;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const ValueSetSelection: React.FC<ConditionSelectionProps> = ({
setActiveCondition(id);

const groupedValueSetByCondition: ConditionToValueSetMap = Object.entries(
valueSetsByCondition
valueSetsByCondition,
)
.map(([conditionId, valSet]) => {
// results for each condition
Expand All @@ -87,7 +87,7 @@ export const ValueSetSelection: React.FC<ConditionSelectionProps> = ({
Object.entries(valueSetsByNameAuthorSystem).map(
([nameAuthorSystem, groupedValueSet]) => {
const mappedSets = mapValueSetsToValueSetType(
groupedValueSet.items
groupedValueSet.items,
);

Object.entries(mappedSets).forEach(([valueSetTypeKey, items]) => {
Expand All @@ -107,7 +107,7 @@ export const ValueSetSelection: React.FC<ConditionSelectionProps> = ({
});

return;
}
},
);

return { [conditionId]: results }; // the value of groupedValueSetByCondition
Expand Down Expand Up @@ -139,16 +139,16 @@ export const ValueSetSelection: React.FC<ConditionSelectionProps> = ({
Object.entries(conditionsByCategory).flatMap(
([conditionId, conditionObj]) => {
return { id: conditionId, name: conditionObj.name };
}
)
},
),
)
.flatMap((conditionsByCategory) => conditionsByCategory);

return (
<div
className={classNames(
"bg-gray-5 margin-top-4 ",
styles.valueSetTemplateContainer
styles.valueSetTemplateContainer,
)}
>
<div className={styles.valueSetTemplateContainer__inner}>
Expand Down
26 changes: 13 additions & 13 deletions query-connector/src/app/queryBuilding/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ValueSet } from "../constants";
import { GroupedValueSet } from '../query/components/customizeQuery/customizeQueryUtils';
import { GroupedValueSet } from "../query/components/customizeQuery/customizeQueryUtils";

// The structure of the data that's coming from the backend
export type ConditionIdToNameMap = {
Expand All @@ -10,8 +10,8 @@ export type CategoryToConditionArrayMap = {
};

export type ConditionIdToValueSetArray = {
[conditionId: string]: ValueSet[]
}
[conditionId: string]: ValueSet[];
};

export type ValueSetsByGroup = {
labs: {
Expand Down Expand Up @@ -119,16 +119,16 @@ export function formatDiseaseDisplay(diseaseName: string) {

/**
* Utility method that returns the number of concepts associated
* with a given value set, with the option to return only
* with a given value set, with the option to return only
* concepts marked as included
* @param valueSet - the GroupedValueSet to run the tally on
* @param filterInclude - boolean to indicate whether to only count
* included concepts (defaults to false)
* @returns A number indicating the tally of relevant concpets
*/
export function tallyConceptsForSingleValueSet (
export function tallyConceptsForSingleValueSet(
valueSet: GroupedValueSet,
filterInclude?: boolean
filterInclude?: boolean,
) {
const selectedTotal = valueSet.items.reduce((sum, vs) => {
const includedConcepts = !!filterInclude
Expand All @@ -139,7 +139,7 @@ export function tallyConceptsForSingleValueSet (
}, 0);

return selectedTotal;
};
}

/**
* Utility method that returns the total number of concepts associated
Expand All @@ -150,13 +150,13 @@ export function tallyConceptsForSingleValueSet (
* included concepts
* @returns A number indicating the tally of relevant concpets
*/
export function tallyConcpetsForValueSetGroup (
export function tallyConcpetsForValueSetGroup(
valueSets: GroupedValueSet[],
filterInclude?: boolean
filterInclude?: boolean,
) {
const selectedTotal = valueSets.reduce((sum, valueSet) => {
const childTotal = tallyConceptsForSingleValueSet(valueSet, filterInclude)
sum += childTotal
const childTotal = tallyConceptsForSingleValueSet(valueSet, filterInclude);
sum += childTotal;
return sum;
}, 0);
return selectedTotal;
Expand All @@ -174,5 +174,5 @@ export const batchSelectConcepts = (input: ValueSet, value: boolean) => {
concept.include = value;
});

return input
};
return input;
};

0 comments on commit 4b50aac

Please sign in to comment.