-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from La-404-Devinci/features/classement
Features/classement
- Loading branch information
Showing
12 changed files
with
150 additions
and
12 deletions.
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
8 changes: 8 additions & 0 deletions
8
backend/prisma/migrations/20240218154047_add_unique_emails/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,8 @@ | ||
/* | ||
Warnings: | ||
- A unique constraint covering the columns `[devinciEmail]` on the table `Account` will be added. If there are existing duplicate values, this will fail. | ||
*/ | ||
-- CreateIndex | ||
CREATE UNIQUE INDEX `Account_devinciEmail_key` ON `Account`(`devinciEmail`); |
15 changes: 15 additions & 0 deletions
15
backend/prisma/migrations/20240218154912_add_defaults/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,15 @@ | ||
/* | ||
Warnings: | ||
- The `lastPixelTime` column on the `Account` table would be dropped and recreated. This will lead to data loss if there is data in the column. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE `Account` MODIFY `isMuted` BOOLEAN NOT NULL DEFAULT false, | ||
MODIFY `isBanned` BOOLEAN NOT NULL DEFAULT false, | ||
MODIFY `isAdmin` BOOLEAN NOT NULL DEFAULT false, | ||
MODIFY `placedPixels` INTEGER NOT NULL DEFAULT 0, | ||
MODIFY `timeAlive` INTEGER NULL, | ||
DROP COLUMN `lastPixelTime`, | ||
ADD COLUMN `lastPixelTime` DATETIME(3) NULL, | ||
MODIFY `lastSentMessageTimes` JSON 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { PrismaClient } from "@prisma/client"; | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
async function main() { | ||
const userCount = Number(process.argv.find(arg => arg.startsWith("userCount="))?.replace(/^userCount=/, "")) ?? 10; | ||
const usersPromise = [] as Promise<unknown>[]; | ||
for(let i = 1; i <= userCount; i++) { | ||
const user = prisma.account.upsert({ | ||
where: { | ||
devinciEmail: `user_${i}@edu.devinci.fr` | ||
}, | ||
update: { | ||
placedPixels: Math.floor(Math.random() * 3000) | ||
}, | ||
create: { | ||
devinciEmail: `user_${i}@edu.devinci.fr`, | ||
placedPixels: Math.floor(Math.random() * 3000) | ||
} | ||
}); | ||
usersPromise.push(user); | ||
} | ||
await Promise.all(usersPromise); | ||
} | ||
|
||
main() | ||
.then(async () => { | ||
await prisma.$disconnect(); | ||
}) | ||
.catch(async (e) => { | ||
console.error(e); | ||
await prisma.$disconnect(); | ||
process.exit(1); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
interface classementItem { | ||
devinciEmail: string; | ||
placedPixels: number; | ||
} | ||
|
||
export default classementItem |
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,5 @@ | ||
interface ChatMessagePayload { | ||
[index: string] : Record<string, any> | ||
} | ||
|
||
export default ChatMessagePayload |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { io } from 'socket.io-client'; | ||
|
||
// "undefined" means the URL will be computed from the `window.location` object | ||
const URL = process.env.NODE_ENV === 'production' ? undefined : 'http://localhost:3000'; | ||
|
||
export const socket = io(URL); |