-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2193 from IntersectMBO/fix/2191-protocol-paramete…
…r-change-ga-is-not-displayed-correctly fix(#2191): protocol parameter change ga is not displayed correctly
- Loading branch information
Showing
12 changed files
with
156 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,18 @@ | ||
select ROW_TO_JSON(epoch_param) from epoch_param order by epoch_no desc limit 1; | ||
SELECT | ||
jsonb_set( | ||
ROW_TO_JSON(epoch_param)::jsonb, | ||
'{cost_model}', | ||
CASE | ||
WHEN cost_model.id IS NOT NULL THEN | ||
ROW_TO_JSON(cost_model)::jsonb | ||
ELSE | ||
'null'::jsonb | ||
END | ||
) AS epoch_param | ||
FROM | ||
epoch_param | ||
LEFT JOIN | ||
cost_model ON epoch_param.cost_model_id = cost_model.id | ||
ORDER BY | ||
epoch_no DESC | ||
LIMIT 1; |
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
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,40 @@ | ||
/** | ||
* Maps an object to a new object by including only the desired keys | ||
* and converting arrays to objects. | ||
* @param obj - The object to map. | ||
* @param desiredKeys - An array of keys to include in the mapped object. | ||
* @returns The mapped object. | ||
*/ | ||
export const mapArrayToObjectByKeys = ( | ||
obj?: Record<string, unknown> | null, | ||
desiredKeys?: string[], | ||
): Record<string, unknown> | null => { | ||
if (!obj || !desiredKeys) { | ||
return null; | ||
} | ||
|
||
return Object.entries(obj).reduce((acc, [key, value]) => { | ||
if (desiredKeys.includes(key) && Array.isArray(value)) { | ||
const arrayToObject = value.reduce<Record<string, unknown>>( | ||
(arrayAcc, arrayValue, index) => { | ||
arrayAcc[index] = arrayValue; | ||
return arrayAcc; | ||
}, | ||
{}, | ||
); | ||
acc[key] = arrayToObject; | ||
} else if ( | ||
typeof value === "object" && | ||
value !== null && | ||
!Array.isArray(value) | ||
) { | ||
acc[key] = mapArrayToObjectByKeys( | ||
value as Record<string, unknown>, | ||
desiredKeys, | ||
); | ||
} else { | ||
acc[key] = value; | ||
} | ||
return acc; | ||
}, {} as Record<string, unknown>); | ||
}; |