-
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4e9312f
add_is_billable_to_profile
RACM048 35d0e1c
Is Billable Filer
RamiroISC 54097e1
Correcciones
RamiroISC 00dce60
Successful test of migrate-profiles-lake
RamiroISC 9dab126
fix: normalize contact__is_billable column name on both lake.server.t…
jackbravo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
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 { OrderByNode, sql } from "kysely"; | ||
|
||
interface UserProfile extends Profiles { | ||
role: string; | ||
|
@@ -95,6 +95,7 @@ | |
jobLevelTitle: data.jobLevelTitle, | ||
department: data.department, | ||
businessUnit: data.businessUnit, | ||
isBillable: data.isBillable, | ||
location: data.location, | ||
country: data.country, | ||
employeeStatus: data.employeeStatus, | ||
|
@@ -277,6 +278,7 @@ | |
benchStatus?: string[]; | ||
employeeStatus?: string[]; | ||
skill?: string[]; | ||
isBillable?: boolean; | ||
itemsPerPage: number; | ||
} | ||
|
||
|
@@ -294,6 +296,7 @@ | |
benchStatus = [], | ||
employeeStatus = [], | ||
skill = [], | ||
isBillable, | ||
itemsPerPage = 50, | ||
}: SearchProfilesFullInput) { | ||
if (page < 1) page = 1; | ||
|
@@ -304,6 +307,7 @@ | |
}; | ||
|
||
if (department.length > 0) { | ||
console.log("Hello world! "+department); | ||
where = { | ||
...where, | ||
department: { in: department }, | ||
|
@@ -348,6 +352,14 @@ | |
}; | ||
} | ||
|
||
if (isBillable != undefined) { | ||
where = { | ||
...where, | ||
isBillable: isBillable, | ||
|
||
}; | ||
} | ||
|
||
// Get ids | ||
const profileIds = await prisma.profiles.findMany({ | ||
select: { | ||
|
@@ -356,6 +368,8 @@ | |
where, | ||
}); | ||
|
||
|
||
|
||
const ids = profileIds.map((id) => id.id); | ||
const count = ids.length; | ||
|
||
|
@@ -377,6 +391,7 @@ | |
preferredName: true, | ||
benchStatus: true, | ||
businessUnit: true, | ||
isBillable: true, | ||
employeeStatus: true, | ||
githubUser: true, | ||
projectMembers: { | ||
|
@@ -502,6 +517,20 @@ | |
} | ||
}); | ||
|
||
const isBillables = await prisma.profiles.groupBy({ | ||
by : ["isBillable"], | ||
where:{ | ||
id: { | ||
in: ids, | ||
}, | ||
}, | ||
orderBy: { | ||
isBillable: "asc", | ||
}, | ||
_count: { | ||
isBillable: true | ||
}, | ||
}); | ||
return { | ||
profiles, | ||
count, | ||
|
@@ -510,6 +539,7 @@ | |
employeeStatuses: convertCountResult(employeeStatuses, "employeeStatus"), | ||
benchStatuses: convertCountResult(benchStatuses, "benchStatus"), | ||
skills, | ||
isBillables: convertBooleanToString(isBillables), | ||
}; | ||
} | ||
|
||
|
@@ -522,6 +552,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, | ||
|
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
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20240502172834_add_is_billable_to_profile/migration.sql
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,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Profiles" ADD COLUMN "isBillable" BOOLEAN NOT NULL DEFAULT true; |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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