Skip to content

Commit

Permalink
merge with gql
Browse files Browse the repository at this point in the history
  • Loading branch information
PineND committed Dec 5, 2024
2 parents d116b59 + 69d94b6 commit f15caca
Show file tree
Hide file tree
Showing 102 changed files with 5,344 additions and 7,911 deletions.
File renamed without changes.
File renamed without changes.
42 changes: 38 additions & 4 deletions .github/workflows/cd-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
build-push:
name: Build and Push Images and Charts
needs: [compute-sha]
uses: ./.github/workflows/cd.yaml
uses: ./.github/workflows/cd-build.yaml
with:
image_tag: ${{ needs.compute-sha.outputs.sha_short }}
chart_ver: 0.1.0-dev.${{ needs.compute-sha.outputs.sha_short }}
Expand All @@ -41,7 +41,7 @@ jobs:
deploy:
name: SSH and Deploy
needs: [compute-sha, build-push]
uses: ./.github/workflows/deploy.yaml
uses: ./.github/workflows/cd-deploy.yaml
with:
environment: development
name: bt-dev-app-${{ needs.compute-sha.outputs.sha_short }}
Expand All @@ -51,11 +51,45 @@ jobs:
ttl: ${{ inputs.ttl }}
frontend:
image:
tag: ${{ needs.compute-sha.outputs.sha_short }}
tag: "${{ needs.compute-sha.outputs.sha_short }}"
backend:
image:
tag: ${{ needs.compute-sha.outputs.sha_short }}
tag: "${{ needs.compute-sha.outputs.sha_short }}"
host: ${{ needs.compute-sha.outputs.sha_short }}.dev.stanfurdtime.com
mongoUri: mongodb://bt-dev-mongo-mongodb.bt.svc.cluster.local:27017/bt
redisUri: redis://bt-dev-redis-master.bt.svc.cluster.local:6379
secrets: inherit

limit-deploy:
name: SSH and Limit Deployments
needs: [deploy]
runs-on: ubuntu-latest
steps:
- name: SSH and Check Deployments
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
set -e # Exit immediately if a command fails
# Get bt-dev-app- deployments sorted by creation timestamp
deployments=$(helm list \
--namespace=bt \
--date \
--short | grep '^bt-dev-app') || true
deployment_count=$(echo "$deployments" | wc -l)
# Check if deployment count > 8
if [ "$deployment_count" -gt 8 ]; then
echo "Too many deployments. Deleting the oldest deployment."
# Get oldest deployment from first line of deployments
oldest_deployment=$(echo "$deployments" | head -n 1)
# Uninstall deployment
helm uninstall "${oldest_deployment}"
else
echo "Deployment count is <= 8."
fi
4 changes: 2 additions & 2 deletions .github/workflows/cd-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
build-push:
name: Build and Push Images and Charts
needs: [branch-check]
uses: ./.github/workflows/cd.yaml
uses: ./.github/workflows/cd-build.yaml
with:
image_tag: prod
chart_ver: "1.0.0"
Expand All @@ -27,7 +27,7 @@ jobs:
deploy:
name: SSH and Deploy
needs: [build-push]
uses: ./.github/workflows/deploy.yaml
uses: ./.github/workflows/cd-deploy.yaml
with:
environment: production
name: bt-prod-app
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cd-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build-push:
name: Build and Push Images and Charts
uses: ./.github/workflows/cd.yaml
uses: ./.github/workflows/cd-build.yaml
with:
image_tag: latest
chart_ver: 0.1.0-stage
Expand All @@ -18,7 +18,7 @@ jobs:
deploy:
name: SSH and Deploy
needs: [build-push]
uses: ./.github/workflows/deploy.yaml
uses: ./.github/workflows/cd-deploy.yaml
with:
environment: staging
name: bt-stage-app
Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/gen.yaml

This file was deleted.

41 changes: 0 additions & 41 deletions .github/workflows/lint.yaml

This file was deleted.

31 changes: 15 additions & 16 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"start": "tsx src/main.ts",
"dev": "tsx watch src/main.ts",
"build": "tsc --noEmit",
"lint": "eslint --ext .tsx,.ts src/ --report-unused-disable-directives",
"generate": "graphql-codegen --config codegen.ts",
"update:catalog": "tsx ./src/scripts/update-catalog.ts",
"update:grades": "tsx --env-file=.env ./src/scripts/update-grade-distributions.ts"
Expand All @@ -15,31 +14,31 @@
"@babel/preset-env": "^7.26.0",
"@babel/preset-typescript": "^7.26.0",
"@graphql-codegen/cli": "5.0.3",
"@graphql-codegen/graphql-modules-preset": "^4.0.11",
"@graphql-codegen/graphql-modules-preset": "^4.0.12",
"@graphql-codegen/introspection": "4.0.3",
"@graphql-codegen/typescript": "^4.1.1",
"@graphql-codegen/typescript-resolvers": "^4.4.0",
"@graphql-codegen/typescript": "^4.1.2",
"@graphql-codegen/typescript-resolvers": "^4.4.1",
"@repo/typescript-config": "*",
"@types/compression": "^1.7.5",
"@types/cors": "^2.8.17",
"@types/express-session": "^1.18.0",
"@types/express-session": "^1.18.1",
"@types/lodash": "^4.17.13",
"@types/node": "^22.9.1",
"@types/node": "^22.10.0",
"@types/passport-google-oauth20": "^2.0.16",
"eslint": "^9.15.0",
"tsx": "^4.19.2",
"typescript": "^5.6.3"
"@types/papaparse": "^5.3.15",
"typescript": "^5.7.2"
},
"dependencies": {
"@apollo/server": "^4.11.2",
"@apollo/server-plugin-response-cache": "^4.1.3",
"@apollo/utils.keyvadapter": "^4.0.0",
"@aws-sdk/client-athena": "^3.696.0",
"@aws-sdk/client-s3": "^3.698.0",
"@escape.tech/graphql-armor": "^3.1.1",
"@graphql-tools/schema": "^10.0.8",
"@graphql-tools/utils": "^10.5.6",
"@keyv/redis": "^4.0.1",
"@aws-sdk/client-athena": "^3.699.0",
"@aws-sdk/client-s3": "^3.701.0",
"@escape.tech/graphql-armor": "^3.1.2",
"@graphql-tools/schema": "^10.0.10",
"@graphql-tools/utils": "^10.6.1",
"@keyv/redis": "^4.0.2",
"@repo/common": "*",
"@repo/sis-api": "*",
"@repo/shared": "*",
Expand All @@ -57,8 +56,8 @@
"helmet": "^8.0.0",
"keyv": "^5.2.1",
"lodash": "^4.17.21",
"mongodb": "^6.10.0",
"mongoose": "^8.8.2",
"mongodb": "^6.11.0",
"mongoose": "^8.8.3",
"papaparse": "^5.4.1",
"passport": "^0.7.0",
"passport-google-oauth20": "^2.0.0",
Expand Down
4 changes: 4 additions & 0 deletions apps/backend/src/modules/grade-distribution/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum Letter {

interface Grade {
letter: Letter;
percentage: number;
count: number;
}

Expand Down Expand Up @@ -96,10 +97,13 @@ export const getDistribution = (distributions: GradeDistributionType[]) => {
}
);

const total = Object.values(distribution).reduce((acc, count) => acc + count);

return Object.entries(distribution).map(
([field, count]) =>
({
letter: letters[field],
percentage: count / total,
count,
}) as Grade
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default gql`
type Grade @cacheControl(maxAge: 1) {
letter: String!
percentage: Float!
count: Int!
}
Expand Down
27 changes: 26 additions & 1 deletion apps/backend/src/scripts/update-catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ const updateTerms = async () => {
// Get all previous terms
let currentTerm: TermType | undefined = terms[0];

while (currentTerm) {
let i = 5;

while (i > 0) {
console.log(currentTerm.name);

if (Number.parseInt(currentTerm.name.slice(0, 4)) < 2022) {
Expand All @@ -266,6 +268,8 @@ const updateTerms = async () => {
);

if (currentTerm) terms.push(currentTerm);

i--;
}

console.log(`Received ${terms.length} terms from SIS API.`);
Expand All @@ -274,6 +278,27 @@ const updateTerms = async () => {
await TermModel.deleteMany({});

await TermModel.insertMany(terms);

// Split terms into batches of 5000
const batchSize = 5000;

for (let i = 0; i < terms.length; i += batchSize) {
const batch = terms.slice(i, i + batchSize);

batch.forEach((doc, index) => {
const instance = new TermModel(doc);
const error = instance.validateSync();
if (error) {
console.error(`Validation error for document ${index}:`, error);
} else {
console.log(`Document ${index} is valid.`);
}
});

console.log(`Inserting batch ${i / batchSize + 1}...`);

await TermModel.insertMany(batch, { ordered: false });
}

console.log(`Completed updating database with new term data.`);
};
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"noEmit": true,
"noEmit": true
},
"include": ["src"]
}
4 changes: 2 additions & 2 deletions apps/datapuller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"course": "tsx src/course.ts"
},
"devDependencies": {
"@types/node": "^22.9.1",
"@types/node": "^22.10.0",
"eslint": "^9.15.0",
"typescript": "^5.6.3"
"typescript": "^5.7.2"
},
"dependencies": {
"@repo/common": "*",
Expand Down
4 changes: 0 additions & 4 deletions apps/frontend/.eslintrc.cjs

This file was deleted.

3 changes: 3 additions & 0 deletions apps/frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from "@repo/eslint-config/index.mjs";

export default [...config];
13 changes: 7 additions & 6 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"moment": "^2.30.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.28.0",
"react-router-dom": "^7.0.1",
"react-select": "^5.8.3",
"recharts": "^2.13.3",
"sass-embedded": "^1.81.0"
Expand All @@ -44,16 +44,17 @@
"@repo/typescript-config": "*",
"@types/lodash": "^4.17.13",
"@types/mapbox-gl": "^3.4.1",
"@types/node": "^22.9.1",
"@types/node": "^22.10.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.3",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^9.15.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.14",
"sass": "^1.81.0",
"sass": "^1.69.0",
"sass-embedded-linux-musl-arm64": "^1.69.0",
"serve": "^14.2.4",
"typescript": "^5.6.3",
"vite": "^5.4.11"
"typescript": "^5.7.2",
"vite": "^6.0.1"
}
}
3 changes: 2 additions & 1 deletion apps/frontend/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Query {
givenName: String
familyName: String
): GradeDistribution!
catalog(year: Int!, semester: Semester!): [Class!]!
catalog(year: Int!, semester: Semester!, query: String): [Class!]!
ping: String! @deprecated(reason: "test")
schedules: [Schedule]
schedule(id: ID!): Schedule
Expand Down Expand Up @@ -101,6 +101,7 @@ type GradeDistribution {

type Grade {
letter: String!
percentage: Float!
count: Int!
}

Expand Down
Loading

0 comments on commit f15caca

Please sign in to comment.