Skip to content

Commit

Permalink
fixed build
Browse files Browse the repository at this point in the history
  • Loading branch information
hkirat committed Apr 16, 2024
1 parent 3646f33 commit 7ff5d5f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 89 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"db:reset": "prisma migrate reset",
"prepare": "husky install",
"studio": "prisma studio",
"studio:docker" : "open http://localhost:5555 || start http://localhost:5555"
"studio:docker": "open http://localhost:5555 || start http://localhost:5555"
},
"dependencies": {
"@auth/prisma-adapter": "^1.0.6",
Expand Down
85 changes: 0 additions & 85 deletions prisma/migrate.ts
Original file line number Diff line number Diff line change
@@ -1,85 +0,0 @@
import db from '../src/db/index';
import fs from 'fs';
import csv from 'csv-parser';
import path from 'path'; // Function to convert CSV to JSON and return as an object

function csvToJson(csvFilePath: string): Promise<any[]> {
return new Promise((resolve, reject) => {
const results: any[] = [];

fs.createReadStream(csvFilePath)
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
resolve(results);
})
.on('error', (error) => reject(error));
});
}

async function main() {
const data: {
email: string;
phone: string;
id: string;
courseId: string;
name: string;
}[] = await csvToJson(path.join(__dirname, './d.csv'));
const allUsers = await db.user.findMany({});
const usersMap: any = {};
allUsers.map((user) => {
if (user && user.id) {
usersMap[user.email || ''] = user?.id;
}
});

//@ts-ignore
const updatedData: {
courseId: number;
email: string;
phone: string;
id: string;
name: string;
}[] = data
.map((x) => ({
email: x.email,
phone: x.phone,
name: x.name,
id: usersMap[x.email] || usersMap[x.phone] || null,
// eslint-disable-next-line
courseId: x.name.includes('1-100')
? 2
: // eslint-disable-next-line
x.name.includes('0-100')
? 3
: // eslint-disable-next-line
x.name.includes('0-1')
? 1
: null,
}))
.filter((x) => x.courseId && x.id);

console.log(updatedData);
for (let i = 0; i < updatedData.length; i++) {
const itemsToPush: {
userId: string;
courseId: number;
}[] = [];

for (let j = 0; j <= 100 && i + j < updatedData.length; j++) {
//@ts-ignore
itemsToPush.push({
userId: updatedData[i + j].id,
courseId: updatedData[i + j].courseId,
});
}
i += 100;
console.log(itemsToPush);
await db.userPurchases.createMany({
data: itemsToPush,
skipDuplicates: true, // Skip 'Bobo'
});
}
}

main();
4 changes: 2 additions & 2 deletions src/actions/refresh-db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export const refreshDb: RefreshDbFn = async () => {
.filter((x) => !x.openToEveryone)
.map(async (course) => {
const courseId = course.appxCourseId.toString();
const data = await checkUserEmailForPurchase(email, courseId);

const data = await checkUserEmailForPurchase(email, courseId);

if (data.data === '1') {
responses.push(course);
Expand Down
1 change: 1 addition & 0 deletions src/app/courses/[courseId]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const Layout = async ({
}: {
params: { courseId: string };
searchParams: QueryParams;
children: any;
}) => {
const courseId = params.courseId;
const hasAccess = await checkAccess(courseId);
Expand Down
2 changes: 1 addition & 1 deletion src/components/comment/CommentInputForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const CommentInputForm = ({
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
// Prevent shortcuts from affecting video when typing in the textarea
event.stopPropagation();
event.stopPropagation();
};

textareaRef.current?.addEventListener('keydown', handleKeyDown);
Expand Down

0 comments on commit 7ff5d5f

Please sign in to comment.