-
Notifications
You must be signed in to change notification settings - Fork 59
Add a Manage Query view to Data Services #1030
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -139,11 +139,13 @@ export const getParamManagerFromValues = (values: any[], keyIndex?: number, valu | |
|
|
||
| if (typeof value === 'object' && value !== null) { | ||
| const paramValues = getParamValues(value); | ||
| const key = keyIndex != undefined && keyIndex >= 0 ? typeof value[keyIndex] === 'object' ? value[keyIndex].value : value[keyIndex] : index + 1; | ||
| return { | ||
| id: index, | ||
| key: keyIndex != undefined && keyIndex >= 0 ? typeof value[keyIndex] === 'object' ? value[keyIndex].value : value[keyIndex] : index + 1, | ||
| value: typeof value[valueIndex] === 'object' ? value[valueIndex].value : value[valueIndex], | ||
| icon: 'query', paramValues | ||
| key: key, | ||
| value: (key === "Query" && valueIndex == 4) ? (typeof value[1] === 'object' ? value[1].value : value[1]) : | ||
| (typeof value[valueIndex] === 'object' ? value[valueIndex].value : value[valueIndex]), | ||
| paramValues | ||
|
Comment on lines
+142
to
+148
Contributor
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. Refactor special-case Query logic and extract magic values to constants. The conditional logic at lines 146-147 introduces a hardcoded special case for value: (key === "Query" && valueIndex == 4) ? (typeof value[1] === 'object' ? value[1].value : value[1]) :
(typeof value[valueIndex] === 'object' ? value[valueIndex].value : value[valueIndex])Issues identified:
Based on learnings, constants should be defined in Consider this refactor: Step 1: Define constants in export const QUERY_KEY = "Query";
export const QUERY_VALUE_INDEX = 4;
export const QUERY_ALTERNATIVE_INDEX = 1;Step 2: Apply this diff: +import { QUERY_KEY, QUERY_VALUE_INDEX, QUERY_ALTERNATIVE_INDEX } from '../../resources/constants';
+
export const getParamManagerFromValues = (values: any[], keyIndex?: number, valueIndex: number = 1): any => {
// ...
const paramValues = values.map((value: any, index: number) => {
if (typeof value === 'object' && value !== null) {
const paramValues = getParamValues(value);
const key = keyIndex != undefined && keyIndex >= 0 ? typeof value[keyIndex] === 'object' ? value[keyIndex].value : value[keyIndex] : index + 1;
+ // Special handling for Query key: use alternative index for value lookup
+ const shouldUseAlternativeIndex = key === QUERY_KEY && valueIndex === QUERY_VALUE_INDEX;
+ const valueIndexToUse = shouldUseAlternativeIndex ? QUERY_ALTERNATIVE_INDEX : valueIndex;
return {
id: index,
key: key,
- value: (key === "Query" && valueIndex == 4) ? (typeof value[1] === 'object' ? value[1].value : value[1]) :
- (typeof value[valueIndex] === 'object' ? value[valueIndex].value : value[valueIndex]),
+ value: typeof value[valueIndexToUse] === 'object' ? value[valueIndexToUse].value : value[valueIndexToUse],
paramValues
};
}
});
}Step 3: Add a comment or documentation explaining why Query keys require special indexing behavior. 🤖 Prompt for AI Agents |
||
| }; | ||
| } else { | ||
| return { value }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.