Skip to content

Commit

Permalink
Code checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
mehallhm committed Oct 16, 2024
1 parent 5b45b6c commit 6277166
Show file tree
Hide file tree
Showing 6 changed files with 922 additions and 638 deletions.
10 changes: 1 addition & 9 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": "node 22"
}
],
"@babel/preset-typescript"
],
"presets": ["@babel/preset-env", "@babel/preset-typescript"],
"plugins": [],
"ignore": ["node_modules"]
}
24 changes: 13 additions & 11 deletions graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,19 @@ const server = new ApolloServer({
// debug: true,
});

if (require.main === module) {
startStandaloneServer(server, {
listen: { port: 3000 },
console.log("hi");

// if (require.main === module) {
startStandaloneServer(server, {
listen: { port: 3000 },
})
.then(({ url }) => {
macros.log(`ready at ${url}`);
return;
})
.then(({ url }) => {
macros.log(`ready at ${url}`);
return;
})
.catch((err) => {
macros.error(`error starting graphql server: ${JSON.stringify(err)}`);
});
}
.catch((err) => {
macros.error(`error starting graphql server: ${JSON.stringify(err)}`);
});
// }

export default server;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"name": "course-catalog-api",
"version": "1.0.9",
"license": "AGPL-3.0",
"type": "module",
"scripts": {
"about:babel-node-ts": "//// This command is used to run Typescript files on the fly. Mainly used in other commands, not standalone",
"babel-node-ts": "babel-node --extensions '.js,.jsx,.ts,.tsx'",
"babel-node-ts": "babel-node --extensions .ts",
"about:dev": "//// Runs the API server - the course catalog API",
"dev": "nodemon --exec ./node_modules/.bin/cross-env NODE_ENV=dev yarn babel-node-ts graphql/index.ts",
"about:dev:notifs": "//// Runs the API server along with the notifications server",
Expand Down Expand Up @@ -141,6 +140,7 @@
"prettier": "3.3.3",
"pretty-quick": "4.0.0",
"prisma": "5",
"tsx": "^4.19.1",
"typescript": "5.6.2",
"yarn-deduplicate": "6.0.2"
},
Expand Down
39 changes: 39 additions & 0 deletions scrapers/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,45 @@ class Main {
)} minutes)\n\n`.green.underline
);
}

async removeExpiredNotifications() {
// TODO: proper error handling on all queries

const inactiveTerms = (
await prisma.termInfo.findMany({
where: {
active: false,
},
select: {
termId: true,
},
})
).map((term) => term.termId);

// Remove inactive followed courses
await prisma.followedCourse.deleteMany({
where: {
course: {
termId: {
in: inactiveTerms,
},
},
},
});

// Remove inactive followed sections
await prisma.followedSection.deleteMany({
where: {
section: {
course: {
termId: {
in: inactiveTerms,
},
},
},
},
});
}
}

const instance = new Main();
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"compilerOptions": {
// Don't output the built files - Babel will do that. Tsc just for checking.
"moduleResolution": "node",
"module": "esnext",
"noEmit": true,
"esModuleInterop": true,
"esModuleInterop": false,
"resolveJsonModule": true,
"lib": ["esnext"],
"skipLibCheck": true,
Expand Down
Loading

0 comments on commit 6277166

Please sign in to comment.