From f1e61ba5b80c8740c4a3a992d7346206cf7c7fe0 Mon Sep 17 00:00:00 2001 From: Cheryl M Date: Sun, 25 Aug 2024 00:35:18 +1000 Subject: [PATCH 1/7] add oAuthProfile to dev seed --- prisma/seed/users.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/prisma/seed/users.ts b/prisma/seed/users.ts index 8194d4d2..7aef3eb8 100644 --- a/prisma/seed/users.ts +++ b/prisma/seed/users.ts @@ -23,6 +23,22 @@ export const populateUsers = async () => { abbreviation: "F", }, }, + oAuthProfiles: { + create: { + providerUserId: "1234567", + providerUsername: "jessica-discord", + provider: { + connectOrCreate: { + where: { + name: "discord", + }, + create: { + name: "discord", + }, + }, + }, + }, + }, }, }); From 85d0ae6a0bd69e2be3be5ae4350315b8b97b4ac3 Mon Sep 17 00:00:00 2001 From: Cheryl M Date: Mon, 26 Aug 2024 15:01:16 +1000 Subject: [PATCH 2/7] add generate gravatar function and update all gravatar links (seed) --- prisma/production-seed/users.ts | 35 +++++++++++++++++---------------- prisma/seed/users.ts | 15 +++++++------- prisma/seed/utils/index.ts | 8 ++++++++ 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/prisma/production-seed/users.ts b/prisma/production-seed/users.ts index 4cefec5b..9428d097 100644 --- a/prisma/production-seed/users.ts +++ b/prisma/production-seed/users.ts @@ -1,6 +1,7 @@ import { prisma } from "../seed/prisma-client"; import { hashPassword } from "../../src/utils/auth"; import { getRoleId } from "../seed/users"; +import { generateGravatarUrl } from "../seed/utils"; export const populateUsersProd = async () => { const roles = await prisma.role.findMany({}); @@ -13,7 +14,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Admin", lastName: "Surname", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("admin@example.com"), timezone: "US/Central", countryCode: "US", }, @@ -34,7 +35,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Jim", lastName: "PO", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("jim@example.com"), timezone: "US/Central", countryCode: "US", }, @@ -54,7 +55,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Razieh", lastName: "PO", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("razieh@example.com"), timezone: "Europe/Madrid", countryCode: "ES", }, @@ -74,7 +75,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Mladen", lastName: "PO", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("mladen@example.com"), timezone: "Europe/Madrid", countryCode: "ES", }, @@ -96,7 +97,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Eury", lastName: "Design", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("eury@example.com"), timezone: "US/Central", countryCode: "US", }, @@ -116,7 +117,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Joe", lastName: "Design", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("joe@example.com"), timezone: "US/Central", countryCode: "US", }, @@ -136,7 +137,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Joseph", lastName: "Design", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("joseph@example.com"), timezone: "America/Lima", countryCode: "PE", }, @@ -156,7 +157,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Austin", lastName: "Design", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("austin@example.com"), timezone: "US/Pacific", countryCode: "US", }, @@ -178,7 +179,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Dan", lastName: "Frontend", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("dan@example.com"), timezone: "US/Eastern", countryCode: "US", }, @@ -198,7 +199,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Jane", lastName: "Frontend", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("jane@example.com"), timezone: "Asia/Tbilisi", countryCode: "GE", }, @@ -218,7 +219,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Timothy", lastName: "Frontend", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("timothy@example.com"), timezone: "Europe/Rome", countryCode: "IT", }, @@ -238,7 +239,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Winnie", lastName: "Frontend", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("winnie@example.com"), timezone: "US/Central", countryCode: "US", }, @@ -260,7 +261,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Cheryl", lastName: "Backend", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("cheryl@example.com"), timezone: "Australia/Melbourne", countryCode: "AU", }, @@ -280,7 +281,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Curt", lastName: "Backend", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("curt@example.com"), timezone: "US/Central", countryCode: "US", }, @@ -300,7 +301,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Josh", lastName: "Backend", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("josh@example.com"), timezone: "US/Pacific", countryCode: "US", }, @@ -320,7 +321,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Tim", lastName: "Backend", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("tim@example.com"), timezone: "US/Central", countryCode: "US", }, @@ -340,7 +341,7 @@ export const populateUsersProd = async () => { emailVerified: true, firstName: "Arman", lastName: "Backend", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("arman@example.com"), timezone: "Asia/Kolkata", countryCode: "IN", }, diff --git a/prisma/seed/users.ts b/prisma/seed/users.ts index 7aef3eb8..40aee7ee 100644 --- a/prisma/seed/users.ts +++ b/prisma/seed/users.ts @@ -1,5 +1,6 @@ import { hashPassword } from "../../src/utils/auth"; import { prisma } from "./prisma-client"; +import { generateGravatarUrl } from "./utils"; export const getRoleId = (roles, name) => { return roles.filter((role) => role.name == name)[0].id; @@ -15,7 +16,7 @@ export const populateUsers = async () => { emailVerified: true, firstName: "Jessica", lastName: "Williamson", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("jessica.williamson@gmail.com"), timezone: "Australia/Melbourne", countryCode: "AU", gender: { @@ -63,7 +64,7 @@ export const populateUsers = async () => { emailVerified: true, firstName: "Larry", lastName: "Castro", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=monsterid&r=x", + avatar: generateGravatarUrl("l.castro@outlook.com"), timezone: "America/Chicago", comment: "Member seems to be inactive", countryCode: "US", @@ -96,7 +97,7 @@ export const populateUsers = async () => { emailVerified: true, firstName: "Leonarda", lastName: "Rowe", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=identicon&r=x", + avatar: generateGravatarUrl("leo.rowe@outlook.com"), timezone: "America/Los_Angeles", comment: "This is a random admin comment", countryCode: "US", @@ -122,7 +123,7 @@ export const populateUsers = async () => { emailVerified: true, firstName: "Joso", lastName: "Mađar", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=wavatar&r=x", + avatar: generateGravatarUrl("JosoMadar@dayrep.com"), timezone: "Europe/Zagreb", comment: "This is a random admin comment", countryCode: "HR", @@ -143,7 +144,7 @@ export const populateUsers = async () => { emailVerified: true, firstName: "Dan", lastName: "Ko", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=wavatar&r=x", + avatar: generateGravatarUrl("dan@random.com"), timezone: "America/Los_Angeles", comment: "No comment", countryCode: "US", @@ -164,7 +165,7 @@ export const populateUsers = async () => { emailVerified: true, firstName: "Not in a voyage", lastName: "Voyage", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=wavatar&r=x", + avatar: generateGravatarUrl("not_in_voyage@example.com"), timezone: "America/New_York", comment: "This user is not in a voyage - does not have the 'voyager' role", @@ -179,7 +180,7 @@ export const populateUsers = async () => { emailVerified: false, firstName: "Yoshi", lastName: "Amano", - avatar: "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x", + avatar: generateGravatarUrl("yoshi@gmail.com"), timezone: "Australia/Melbourne", countryCode: "AU", gender: { diff --git a/prisma/seed/utils/index.ts b/prisma/seed/utils/index.ts index a412bca3..a90e8f7d 100644 --- a/prisma/seed/utils/index.ts +++ b/prisma/seed/utils/index.ts @@ -1,4 +1,5 @@ import { prisma } from "../prisma-client"; +import * as crypto from "crypto"; export const addDays = (date, days: number) => { const newDate = new Date(date); @@ -26,3 +27,10 @@ export const getRandomDateDuringSprint = async (sprintId) => { }); return addDays(sprint?.startDate, Math.floor(Math.random() * 6)); }; + +export const generateGravatarUrl = (email: string = "noemail@example.com") => { + const themes = ["identicon", "monsterid", "wavatar", "retro", "robohash"]; + const hash = crypto.createHash("sha256").update(email).digest("hex"); + return `https://gravatar.com/avatar/${hash}?s=200&r=g&d=${themes[Math.floor(Math.random() * themes.length)]} +`; +}; From 3e2bfe077c1773b01b52b9975d0d33b52b0305c1 Mon Sep 17 00:00:00 2001 From: Cheryl M Date: Mon, 26 Aug 2024 22:23:04 +1000 Subject: [PATCH 3/7] update checkin form seed --- prisma/seed/forms/checkinform.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prisma/seed/forms/checkinform.ts b/prisma/seed/forms/checkinform.ts index a87e6672..4ca4dde3 100644 --- a/prisma/seed/forms/checkinform.ts +++ b/prisma/seed/forms/checkinform.ts @@ -178,7 +178,7 @@ export const populateCheckinForm = async () => { name: "teamMembersCheckbox", }, }, - text: "Is there anyone on your team who has not been super helpful, kind, hard-working, etc. and deserves a shout-out in the Chingu Weekly? If so, please add his/her Discord username here:", + text: "Is there anyone on your team who has been super helpful, kind, hard-working, etc. and deserves a shout-out in the Chingu Weekly? If so, please add his/her Discord username here:", answerRequired: false, }, { @@ -235,7 +235,7 @@ export const populateCheckinForm = async () => { }, }, text: "Is there anything else you'd like to tell us about your Voyage Guide?", - answerRequired: true, + answerRequired: false, }, { order: 12, From 44bee20df1661585b6e80adbcae5f1f625eb2ad2 Mon Sep 17 00:00:00 2001 From: Cheryl M Date: Mon, 26 Aug 2024 22:50:03 +1000 Subject: [PATCH 4/7] update change log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f93fea35..f2c3697c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -92,6 +92,7 @@ Another example [here](https://co-pilot.dev/changelog) - Fix form responses giving error and not inserting values when the boolean value is false ([#156](https://github.com/chingu-x/chingu-dashboard-be/pull/156)) - Fix a bug for check on voyageTeamMemberId ([#159](https://github.com/chingu-x/chingu-dashboard-be/pull/159)) - Fix users unit test failing due to a schema change +- Fix seed data for alpha test (check in form question changes, gravatar) ([#190](https://github.com/chingu-x/chingu-dashboard-be/pull/190)) ### Removed From 9e4b49a9623fcd12e7a734fd72612c3ba8aebdc6 Mon Sep 17 00:00:00 2001 From: Cheryl M Date: Wed, 28 Aug 2024 10:56:08 +1000 Subject: [PATCH 5/7] mark OAuthProvider name as unique --- prisma/schema/user.prisma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prisma/schema/user.prisma b/prisma/schema/user.prisma index eaf2dd4b..f87d280d 100644 --- a/prisma/schema/user.prisma +++ b/prisma/schema/user.prisma @@ -65,7 +65,7 @@ model UserRole { model OAuthProvider { id Int @id @default(autoincrement()) - name String + name String @unique createdAt DateTime @default(now()) @db.Timestamptz() updatedAt DateTime @updatedAt From 1795395b231e694a1ba9c24a6cc22b927ab4787e Mon Sep 17 00:00:00 2001 From: Cheryl M Date: Wed, 28 Aug 2024 10:58:22 +1000 Subject: [PATCH 6/7] generate prisma migration --- .../migration.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 prisma/migrations/20240828005752_mark_oauthprovider_name_unique/migration.sql diff --git a/prisma/migrations/20240828005752_mark_oauthprovider_name_unique/migration.sql b/prisma/migrations/20240828005752_mark_oauthprovider_name_unique/migration.sql new file mode 100644 index 00000000..d2d6e340 --- /dev/null +++ b/prisma/migrations/20240828005752_mark_oauthprovider_name_unique/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - A unique constraint covering the columns `[name]` on the table `OAuthProvider` will be added. If there are existing duplicate values, this will fail. + +*/ +-- CreateIndex +CREATE UNIQUE INDEX "OAuthProvider_name_key" ON "OAuthProvider"("name"); From 7d035f1536addfa888781763bd5569b9c0d5b5d5 Mon Sep 17 00:00:00 2001 From: Josh Hinman Date: Thu, 29 Aug 2024 17:51:01 -0700 Subject: [PATCH 7/7] updated question 8, removed 12 --- prisma/seed/forms/checkinform.ts | 43 ++------------------------------ 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/prisma/seed/forms/checkinform.ts b/prisma/seed/forms/checkinform.ts index a87e6672..13d50578 100644 --- a/prisma/seed/forms/checkinform.ts +++ b/prisma/seed/forms/checkinform.ts @@ -178,14 +178,14 @@ export const populateCheckinForm = async () => { name: "teamMembersCheckbox", }, }, - text: "Is there anyone on your team who has not been super helpful, kind, hard-working, etc. and deserves a shout-out in the Chingu Weekly? If so, please add his/her Discord username here:", + text: "Is there anyone on your team who has been super helpful, kind, hard-working, etc. and deserves a shout-out in the Chingu Weekly? If so, please add his/her Discord username here:", answerRequired: false, }, { order: 9, inputType: { connect: { - name: "text", + name: "teamMembersCheckbox", }, }, text: "Please share any personal or team achievements this week here. (ex. held a meeting, teammate got a job, had a pair programming session, learned a valuable team lesson, solved a challenging problem).", @@ -239,45 +239,6 @@ export const populateCheckinForm = async () => { }, { order: 12, - inputType: { - connect: { - name: "radio", - }, - }, - text: "What is your role in your team?", - answerRequired: true, - optionGroup: { - create: { - name: "checkin-form-role", - optionChoices: { - createMany: { - data: [ - { - text: "Product Owner", - }, - { - text: "Scrum Master", - }, - { - text: "Web Developer", - }, - { - text: "UI/UX Designer", - }, - { - text: "Data Scientist", - }, - { - text: "Voyage Guide", - }, - ], - }, - }, - }, - }, - }, - { - order: 13, inputType: { connect: { name: "text",