haifxu commented on code in PR #10469:
URL: https://github.com/apache/inlong/pull/10469#discussion_r1648471683
##########
inlong-dashboard/src/ui/pages/GroupDetail/Audit/config.tsx:
##########
@@ -93,14 +93,53 @@ export const toChartData = (source, sourceDataMap) => {
};
export const toTableData = (source, sourceDataMap) => {
- return Object.keys(sourceDataMap)
+ const map = Object.keys(sourceDataMap)
.reverse()
.map(logTs => ({
...sourceDataMap[logTs],
logTs,
}));
+ return getSourceDataWithPercent(source, map);
};
+export const getSourceDataWithPercent = (sourceKeys, sourceMap) => {
+ const auditIds = Array.from(
+ new Set(Object.values(sourceKeys).map(({ auditId }) => parseInt(auditId))),
+ );
+ return sourceMap.map(source => {
+ for (const auditId of auditIds) {
+ if (!(auditId in source)) {
+ source[auditId] = 0;
+ }
+ }
+ let newSource = {};
+ const keys = Object.keys(source).filter(key => key !== 'logTs');
+ const firstKey = keys[0];
+ const firstValue = source[firstKey];
+ newSource[firstKey] = firstValue.toString();
+ for (let key of keys.slice(1)) {
+ if (key !== 'logTs') {
+ let diff = getDiff(firstValue, source[key]);
+ newSource[key] = `${source[key]} (${diff})`;
+ }
+ }
+ newSource['logTs'] = source['logTs'];
+ return newSource;
+ });
+};
+
+export const getDiff = (first, current) => {
+ if (first === 0) {
+ return '0%';
+ }
+ let result;
+ const diff = parseFloat(((current / first - 1) * 100).toFixed(3));
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]