-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: laixingyou <[email protected]>
- Loading branch information
1 parent
0afe701
commit c54c5dc
Showing
12 changed files
with
136 additions
and
114 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
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
46 changes: 0 additions & 46 deletions
46
apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/utils.ts
This file was deleted.
Oops, something went wrong.
92 changes: 92 additions & 0 deletions
92
apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/utils.tsx
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,92 @@ | ||
import { IoPeopleCircle } from 'react-icons/io5'; | ||
import Image from 'next/image'; | ||
|
||
export const getMaxDomain = (tableData) => { | ||
if (tableData?.length > 0) { | ||
const filterData = tableData?.map((item) => { | ||
let filterCount = item?.contributionTypeList?.reduce( | ||
(acc, current) => acc + current.contribution, | ||
0 | ||
); | ||
return { ...item, filterCount }; | ||
}); | ||
let maxCountElement = filterData?.reduce((prev, current) => | ||
prev?.filterCount > current.filterCount ? prev : current | ||
); | ||
return maxCountElement.filterCount; | ||
} else { | ||
return 0; | ||
} | ||
}; | ||
export const getDomainData = (data, contributionTypeMap) => { | ||
let arr = data.map((item) => { | ||
return { ...item, ...contributionTypeMap[item.contributionType] }; | ||
}); | ||
const result = []; | ||
arr.forEach(({ color, contribution, text, type }) => { | ||
const domainType = result.find((z) => z.type === type); | ||
if (domainType) { | ||
domainType.contribution += contribution; | ||
domainType.childern.push({ text, contribution }); | ||
} else { | ||
result.push({ | ||
type, | ||
color, | ||
contribution, | ||
childern: [{ text, contribution }], | ||
}); | ||
} | ||
}); | ||
return result.sort((a, b) => { | ||
if (a.type < b.type) { | ||
return -1; | ||
} | ||
if (a.type > b.type) { | ||
return 1; | ||
} | ||
return 0; | ||
}); | ||
}; | ||
|
||
export const getIcons = (origin, name) => { | ||
switch (origin) { | ||
case 'github': | ||
return ( | ||
<div className="relative mr-2 h-6 w-6 overflow-hidden rounded-full border border-gray-100"> | ||
<Image | ||
src={'https://github.com/' + name + '.png'} | ||
onError={(e) => (e.currentTarget.src = '/images/github.png')} | ||
unoptimized | ||
fill={true} | ||
style={{ | ||
objectFit: 'cover', | ||
}} | ||
alt="icon" | ||
placeholder="blur" | ||
blurDataURL="/images/github.png" | ||
/> | ||
</div> | ||
); | ||
case 'gitee': | ||
return ( | ||
<div className="relative mr-2 h-6 w-6 overflow-hidden rounded-full border border-gray-100"> | ||
<Image | ||
src={'https://gitee.com/' + name + '.png'} | ||
onError={(e) => | ||
(e.currentTarget.src = '/images/logos/gitee-red.svg') | ||
} | ||
unoptimized | ||
fill={true} | ||
style={{ | ||
objectFit: 'cover', | ||
}} | ||
alt="icon" | ||
placeholder="blur" | ||
blurDataURL="/images/logos/gitee-red.svg" | ||
/> | ||
</div> | ||
); | ||
default: | ||
return <IoPeopleCircle />; | ||
} | ||
}; |
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
Oops, something went wrong.