From 4e9312fe0669b72aba963656061c78a81fb46d38 Mon Sep 17 00:00:00 2001 From: Ramiro Date: Mon, 6 May 2024 12:20:12 -0600 Subject: [PATCH 1/5] add_is_billable_to_profile --- app/kysely.d.ts | 1 + app/lake.server.tsx | 2 ++ app/profileMigration.server.ts | 3 ++- .../20240502172834_add_is_billable_to_profile/migration.sql | 2 ++ prisma/schema.prisma | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 prisma/migrations/20240502172834_add_is_billable_to_profile/migration.sql diff --git a/app/kysely.d.ts b/app/kysely.d.ts index bafe20cc..7e1caddb 100644 --- a/app/kysely.d.ts +++ b/app/kysely.d.ts @@ -220,6 +220,7 @@ export interface Profiles { firstName: string; githubUser: string | null; id: string; + isBillable: Generated; jobLevelTier: string | null; jobLevelTitle: string | null; jobTitleId: string | null; diff --git a/app/lake.server.tsx b/app/lake.server.tsx index 4a26dfd7..d0ad4ea8 100644 --- a/app/lake.server.tsx +++ b/app/lake.server.tsx @@ -10,6 +10,7 @@ export async function findProfileData(email: string) { const query = `SELECT contact__wizeos_profile_id, contact__employee_number, contact__email, contact__first_name, contact__preferred_name, contact__last_name, contact__photo__url, + contact__is_billable, contact__location, contact__country, contact__status, contact__department, contact__business_unit, contact__employee_status, @@ -41,6 +42,7 @@ export async function getActiveProfiles() { const query = `SELECT contact__wizeos_profile_id, contact__employee_number, contact__email, contact__first_name, contact__preferred_name, contact__last_name, contact__photo__url, + contact__is_billable, contact__location, contact__country, contact__status, contact__department, contact__business_unit, contact__employee_status, diff --git a/app/profileMigration.server.ts b/app/profileMigration.server.ts index cc29838d..6825c869 100644 --- a/app/profileMigration.server.ts +++ b/app/profileMigration.server.ts @@ -10,7 +10,7 @@ async function getMappedProfiles(): Promise { email: lakeProfile.contact__email, firstName: lakeProfile.contact__first_name, preferredName: - lakeProfile.contact__preferred_name || lakeProfile.contact__first_name, + lakeProfile.contact__preferred_name || lakeProfile.contact__first_name, lastName: lakeProfile.contact__last_name, department: lakeProfile.contact__department, jobLevelTier: lakeProfile.contact__wizeos__level, @@ -21,6 +21,7 @@ async function getMappedProfiles(): Promise { employeeStatus: lakeProfile.contact__employee_status, benchStatus: lakeProfile.contact__status, businessUnit: lakeProfile.contact__business_unit, + isBillable: lakeProfile.contact__is_billable, }; }); return mappedProfiles; diff --git a/prisma/migrations/20240502172834_add_is_billable_to_profile/migration.sql b/prisma/migrations/20240502172834_add_is_billable_to_profile/migration.sql new file mode 100644 index 00000000..1c95902c --- /dev/null +++ b/prisma/migrations/20240502172834_add_is_billable_to_profile/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Profiles" ADD COLUMN "isBillable" BOOLEAN NOT NULL DEFAULT true; \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index d0c84abe..bdcfaf18 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -58,6 +58,7 @@ model Profiles { jobLevelTitle String? department String? businessUnit String? + isBillable Boolean @default(true) // - null // - Horizontal // - Innovation From 35d0e1c90d4de83e3ecc6488441ed69aeb99cc79 Mon Sep 17 00:00:00 2001 From: RamiroISC Date: Mon, 10 Jun 2024 10:02:27 -0600 Subject: [PATCH 2/5] Is Billable Filer --- app/models/profile.server.ts | 43 +++++++++++++++++++++++++++++++++- app/routes/profiles._index.tsx | 18 +++++++++++++- prisma/seed.ts | 12 ++++++++++ s | 30 ++++++++++++++++++++++++ "\357\200\226\357\200\226" | 30 ++++++++++++++++++++++++ 5 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 s create mode 100644 "\357\200\226\357\200\226" diff --git a/app/models/profile.server.ts b/app/models/profile.server.ts index 93a0abed..eb07176b 100644 --- a/app/models/profile.server.ts +++ b/app/models/profile.server.ts @@ -8,7 +8,9 @@ import type { PrismaClient, } from "@prisma/client"; import { Prisma } from "@prisma/client"; -import { sql } from "kysely"; +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 @@ export async function updateProfile( 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 @@ interface SearchProfilesFullInput { benchStatus?: string[]; employeeStatus?: string[]; skill?: string[]; + isBillable?: boolean; itemsPerPage: number; } @@ -294,6 +298,7 @@ export async function searchProfilesFull({ benchStatus = [], employeeStatus = [], skill = [], + isBillable, itemsPerPage = 50, }: SearchProfilesFullInput) { if (page < 1) page = 1; @@ -304,6 +309,7 @@ export async function searchProfilesFull({ }; if (department.length > 0) { + console.log("Hello world! "+department); where = { ...where, department: { in: department }, @@ -348,6 +354,14 @@ export async function searchProfilesFull({ }; } + if (isBillable != undefined) { + where = { + ...where, + isBillable: isBillable, + + }; + } + // Get ids const profileIds = await prisma.profiles.findMany({ select: { @@ -356,6 +370,8 @@ export async function searchProfilesFull({ where, }); + + const ids = profileIds.map((id) => id.id); const count = ids.length; @@ -377,6 +393,7 @@ export async function searchProfilesFull({ preferredName: true, benchStatus: true, businessUnit: true, + isBillable: true, employeeStatus: true, githubUser: true, projectMembers: { @@ -502,6 +519,20 @@ export async function searchProfilesFull({ } }); + 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 @@ export async function searchProfilesFull({ employeeStatuses: convertCountResult(employeeStatuses, "employeeStatus"), benchStatuses: convertCountResult(benchStatuses, "benchStatus"), skills, + isBillables: convertBooleanToString(isBillables), }; } @@ -522,6 +554,15 @@ const convertCountResult = (countResult: any[], countField: string) => { }); }; +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, diff --git a/app/routes/profiles._index.tsx b/app/routes/profiles._index.tsx index cef6f2fd..b8790eca 100644 --- a/app/routes/profiles._index.tsx +++ b/app/routes/profiles._index.tsx @@ -93,6 +93,7 @@ const FILTERS = [ "businessUnit", "benchStatus", "skill", + "isBillable", ]; interface LoaderData { @@ -109,7 +110,10 @@ export const loader: LoaderFunction = async ({ request }) => { const benchStatus = url.searchParams.getAll("benchStatus"); const employeeStatus = url.searchParams.getAll("employeeStatus"); const skill = url.searchParams.getAll("skill"); - + + const isBillable = url.searchParams.get("isBillable") === null ? + undefined : + url.searchParams.get("isBillable") === "true"; const data = await searchProfilesFull({ searchTerm, page, @@ -118,6 +122,7 @@ export const loader: LoaderFunction = async ({ request }) => { benchStatus, employeeStatus, skill, + isBillable, itemsPerPage: ITEMS_PER_PAGE, }); @@ -147,6 +152,7 @@ const Profiles = () => { benchStatuses, employeeStatuses, skills, + isBillables, }, } = useLoaderData() as unknown as LoaderData; const theme = useTheme(); @@ -267,6 +273,13 @@ const Profiles = () => { items={benchStatuses} /> ) : null} + {isBillables.length > 0 ?( + + ) : null} @@ -365,6 +378,9 @@ const Profiles = () => { {item.employeeStatus} + + {item.isBillable} + {item.projectMembers.length > 0 ? ( <> {item.projectMembers.map((projectMember, index) => ( diff --git a/prisma/seed.ts b/prisma/seed.ts index 5d00de81..b0f3c212 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -146,6 +146,18 @@ async function seed() { department: "Engineering", }, }); + await db.profiles.upsert({ + where: { email: "ramiro.cardona@in.wizeline.com" }, + update: {}, + create: { + email: "ramiro.cardona@in.wizeline.com", + firstName: "Ramiro", + preferredName: "Ramiro", + lastName: "Cardona", + department: "Engineering", + isBillable: false, + }, + }); await db.profiles.upsert({ where: { email: "fernanda.vargas@wizeline.com" }, update: {}, diff --git a/s b/s new file mode 100644 index 00000000..1af8503f --- /dev/null +++ b/s @@ -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 diff --git "a/\357\200\226\357\200\226" "b/\357\200\226\357\200\226" new file mode 100644 index 00000000..1af8503f --- /dev/null +++ "b/\357\200\226\357\200\226" @@ -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 From 54097e167a073619c244529889cf6a8edb5fd2a1 Mon Sep 17 00:00:00 2001 From: RamiroISC Date: Tue, 11 Jun 2024 10:35:17 -0600 Subject: [PATCH 3/5] Correcciones --- app/models/profile.server.ts | 2 -- s | 30 ------------------------------ "\357\200\226\357\200\226" | 30 ------------------------------ 3 files changed, 62 deletions(-) delete mode 100644 s delete mode 100644 "\357\200\226\357\200\226" diff --git a/app/models/profile.server.ts b/app/models/profile.server.ts index eb07176b..53e67fd9 100644 --- a/app/models/profile.server.ts +++ b/app/models/profile.server.ts @@ -8,9 +8,7 @@ import type { PrismaClient, } from "@prisma/client"; import { Prisma } from "@prisma/client"; -import { id } from "date-fns/locale"; import { OrderByNode, sql } from "kysely"; -import { boolean } from "zod"; interface UserProfile extends Profiles { role: string; diff --git a/s b/s deleted file mode 100644 index 1af8503f..00000000 --- a/s +++ /dev/null @@ -1,30 +0,0 @@ -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 diff --git "a/\357\200\226\357\200\226" "b/\357\200\226\357\200\226" deleted file mode 100644 index 1af8503f..00000000 --- "a/\357\200\226\357\200\226" +++ /dev/null @@ -1,30 +0,0 @@ -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 From 00dce60c193aa576942055c68254d1e35e8e65cd Mon Sep 17 00:00:00 2001 From: RamiroISC Date: Tue, 11 Jun 2024 14:46:28 -0600 Subject: [PATCH 4/5] Successful test of migrate-profiles-lake --- app/lake.server.tsx | 2 +- app/models/profile.server.ts | 2 +- app/profileMigration.server.ts | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/lake.server.tsx b/app/lake.server.tsx index d0ad4ea8..d201306f 100644 --- a/app/lake.server.tsx +++ b/app/lake.server.tsx @@ -42,7 +42,7 @@ export async function getActiveProfiles() { const query = `SELECT contact__wizeos_profile_id, contact__employee_number, contact__email, contact__first_name, contact__preferred_name, contact__last_name, contact__photo__url, - contact__is_billable, + contact__isBillable, contact__location, contact__country, contact__status, contact__department, contact__business_unit, contact__employee_status, diff --git a/app/models/profile.server.ts b/app/models/profile.server.ts index 53e67fd9..e95310f2 100644 --- a/app/models/profile.server.ts +++ b/app/models/profile.server.ts @@ -8,7 +8,7 @@ import type { PrismaClient, } from "@prisma/client"; import { Prisma } from "@prisma/client"; -import { OrderByNode, sql } from "kysely"; +import { sql } from "kysely"; interface UserProfile extends Profiles { role: string; diff --git a/app/profileMigration.server.ts b/app/profileMigration.server.ts index 6825c869..90a7429f 100644 --- a/app/profileMigration.server.ts +++ b/app/profileMigration.server.ts @@ -5,6 +5,7 @@ import type { PrismaClient, Prisma } from "@prisma/client"; async function getMappedProfiles(): Promise { const activeProfiles = await getActiveProfiles(); const mappedProfiles = activeProfiles.map((lakeProfile) => { + const isBillable = lakeProfile.contact__is_billable === "Billable"; return { id: String(lakeProfile.contact__employee_number), email: lakeProfile.contact__email, @@ -21,7 +22,7 @@ async function getMappedProfiles(): Promise { employeeStatus: lakeProfile.contact__employee_status, benchStatus: lakeProfile.contact__status, businessUnit: lakeProfile.contact__business_unit, - isBillable: lakeProfile.contact__is_billable, + isBillable: isBillable, }; }); return mappedProfiles; From 9dab126331d5b2f173d3f801ab7f37da4675491c Mon Sep 17 00:00:00 2001 From: Joaquin Bravo Contreras Date: Thu, 20 Jun 2024 11:09:22 -0600 Subject: [PATCH 5/5] fix: normalize contact__is_billable column name on both lake.server.tsx funcionts --- app/lake.server.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lake.server.tsx b/app/lake.server.tsx index d201306f..d0ad4ea8 100644 --- a/app/lake.server.tsx +++ b/app/lake.server.tsx @@ -42,7 +42,7 @@ export async function getActiveProfiles() { const query = `SELECT contact__wizeos_profile_id, contact__employee_number, contact__email, contact__first_name, contact__preferred_name, contact__last_name, contact__photo__url, - contact__isBillable, + contact__is_billable, contact__location, contact__country, contact__status, contact__department, contact__business_unit, contact__employee_status,