zhaoyingbo 18a95387ee
All checks were successful
CI Monitor CI/CD / build-image (push) Successful in 33s
CI Monitor CI/CD / deploy (push) Successful in 37s
chore: 更新lint-staged和commitlint配置
2024-07-25 01:09:24 +00:00

40 lines
944 B
TypeScript

import db from "../../db"
import { Gitlab } from "../../types/gitlab"
const getFullUserMap = async (fullPipelineList: Gitlab.PipelineDetail[][]) => {
const userList: Gitlab.User[] = []
fullPipelineList.forEach((fullPipeline) => {
fullPipeline.forEach((item) => {
if (item.user && !userList.find((v) => v.id === item.user?.id)) {
userList.push(item.user)
}
})
})
const dbUserInfo = await Promise.all(
userList
.filter((v) => v.id !== 0)
.map((user) =>
db.user.upsert({
user_id: user.id,
username: user.username,
name: user.name,
avatar_url: user.avatar_url,
web_url: user.web_url,
})
)
)
const userMap: Record<string, string> = {}
dbUserInfo.forEach((item) => {
if (!item) return
userMap[item.user_id] = item.id
})
return userMap
}
const manageUser = {
getFullUserMap,
}
export default manageUser