-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add new columns to perfile table #305 #332
Changes from 2 commits
4e9312f
35d0e1c
54097e1
00dce60
9dab126
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 |
---|---|---|
|
@@ -8,7 +8,9 @@ | |
PrismaClient, | ||
} from "@prisma/client"; | ||
import { Prisma } from "@prisma/client"; | ||
import { sql } from "kysely"; | ||
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. none of these changes from lines 11 to 13 seem necessary. ESLint says we are importing but not using those names. 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. |
||
import { id } from "date-fns/locale"; | ||
import { OrderByNode, sql } from "kysely"; | ||
import { boolean } from "zod"; | ||
|
||
interface UserProfile extends Profiles { | ||
role: string; | ||
|
@@ -95,6 +97,7 @@ | |
jobLevelTitle: data.jobLevelTitle, | ||
department: data.department, | ||
businessUnit: data.businessUnit, | ||
isBillable: data.isBillable, | ||
location: data.location, | ||
country: data.country, | ||
employeeStatus: data.employeeStatus, | ||
|
@@ -277,6 +280,7 @@ | |
benchStatus?: string[]; | ||
employeeStatus?: string[]; | ||
skill?: string[]; | ||
isBillable?: boolean; | ||
itemsPerPage: number; | ||
} | ||
|
||
|
@@ -294,6 +298,7 @@ | |
benchStatus = [], | ||
employeeStatus = [], | ||
skill = [], | ||
isBillable, | ||
itemsPerPage = 50, | ||
}: SearchProfilesFullInput) { | ||
if (page < 1) page = 1; | ||
|
@@ -304,6 +309,7 @@ | |
}; | ||
|
||
if (department.length > 0) { | ||
console.log("Hello world! "+department); | ||
where = { | ||
...where, | ||
department: { in: department }, | ||
|
@@ -348,6 +354,14 @@ | |
}; | ||
} | ||
|
||
if (isBillable != undefined) { | ||
where = { | ||
...where, | ||
isBillable: isBillable, | ||
|
||
}; | ||
} | ||
|
||
// Get ids | ||
const profileIds = await prisma.profiles.findMany({ | ||
select: { | ||
|
@@ -356,6 +370,8 @@ | |
where, | ||
}); | ||
|
||
|
||
|
||
const ids = profileIds.map((id) => id.id); | ||
const count = ids.length; | ||
|
||
|
@@ -377,6 +393,7 @@ | |
preferredName: true, | ||
benchStatus: true, | ||
businessUnit: true, | ||
isBillable: true, | ||
employeeStatus: true, | ||
githubUser: true, | ||
projectMembers: { | ||
|
@@ -502,6 +519,20 @@ | |
} | ||
}); | ||
|
||
const isBillables = await prisma.profiles.groupBy({ | ||
by : ["isBillable"], | ||
where:{ | ||
id: { | ||
in: ids, | ||
}, | ||
}, | ||
orderBy: { | ||
isBillable: "asc", | ||
}, | ||
_count: { | ||
isBillable: true | ||
}, | ||
}); | ||
return { | ||
profiles, | ||
count, | ||
|
@@ -510,6 +541,7 @@ | |
employeeStatuses: convertCountResult(employeeStatuses, "employeeStatus"), | ||
benchStatuses: convertCountResult(benchStatuses, "benchStatus"), | ||
skills, | ||
isBillables: convertBooleanToString(isBillables), | ||
}; | ||
} | ||
|
||
|
@@ -522,6 +554,15 @@ | |
}); | ||
}; | ||
|
||
const convertBooleanToString = (countResult : any[]) => { | ||
return countResult.map(item => ({ | ||
name: item.isBillable.toString(), | ||
count: item._count.isBillable | ||
})); | ||
}; | ||
|
||
|
||
|
||
export async function searchProfiles( | ||
searchTerm: string, | ||
project: string | null = null, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Profiles" ADD COLUMN "isBillable" BOOLEAN NOT NULL DEFAULT true; |
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. What is this file? Is it necessary? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
diff.astextplain.textconv=astextplain | ||
filter.lfs.clean=git-lfs clean -- %f | ||
filter.lfs.smudge=git-lfs smudge -- %f | ||
filter.lfs.process=git-lfs filter-process | ||
filter.lfs.required=true | ||
http.sslbackend=openssl | ||
http.sslcainfo=C:/Program Files/Git/mingw64/etc/ssl/certs/ca-bundle.crt | ||
core.autocrlf=true | ||
core.fscache=true | ||
core.symlinks=false | ||
pull.rebase=false | ||
credential.helper=manager | ||
credential.https://dev.azure.com.usehttppath=true | ||
init.defaultbranch=master | ||
filter.lfs.clean=git-lfs clean -- %f | ||
filter.lfs.smudge=git-lfs smudge -- %f | ||
filter.lfs.process=git-lfs filter-process | ||
filter.lfs.required=true | ||
user.name=Ramiro | ||
user.email=ramirocmcm@gmail.com | ||
core.repositoryformatversion=0 | ||
core.filemode=false | ||
core.bare=false | ||
core.logallrefupdates=true | ||
core.symlinks=false | ||
core.ignorecase=true | ||
remote.origin.url=https://github.com/WizelineLabs/project-lab.git | ||
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* | ||
branch.main.remote=origin | ||
branch.main.merge=refs/heads/main |
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. What is this file? Is it necessary? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
diff.astextplain.textconv=astextplain | ||
filter.lfs.clean=git-lfs clean -- %f | ||
filter.lfs.smudge=git-lfs smudge -- %f | ||
filter.lfs.process=git-lfs filter-process | ||
filter.lfs.required=true | ||
http.sslbackend=openssl | ||
http.sslcainfo=C:/Program Files/Git/mingw64/etc/ssl/certs/ca-bundle.crt | ||
core.autocrlf=true | ||
core.fscache=true | ||
core.symlinks=false | ||
pull.rebase=false | ||
credential.helper=manager | ||
credential.https://dev.azure.com.usehttppath=true | ||
init.defaultbranch=master | ||
filter.lfs.clean=git-lfs clean -- %f | ||
filter.lfs.smudge=git-lfs smudge -- %f | ||
filter.lfs.process=git-lfs filter-process | ||
filter.lfs.required=true | ||
user.name=Ramiro | ||
user.email=ramirocmcm@gmail.com | ||
core.repositoryformatversion=0 | ||
core.filemode=false | ||
core.bare=false | ||
core.logallrefupdates=true | ||
core.symlinks=false | ||
core.ignorecase=true | ||
remote.origin.url=https://github.com/WizelineLabs/project-lab.git | ||
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* | ||
branch.main.remote=origin | ||
branch.main.merge=refs/heads/main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tested these changes? You need to run