Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
name: Build problem list and static files
needs: test
runs-on: ubuntu-latest
env:
REACT_APP_PROBLEM_SET: ${{secrets.REACT_APP_PROBLEM_SET}}
steps:
- uses: actions/checkout@v4
- run: git submodule sync
Expand Down
1 change: 0 additions & 1 deletion src/problems

This file was deleted.

24 changes: 24 additions & 0 deletions src/problems.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

/**
* Here you define the different types of questions
*/
const questionTypeList = [
'private-problems',
'public-problems'
]

/**
* Depending on the REACT_APP_PROBLEM_SET, it returns am ESM module based off that ones
* @returns ESM Module Import for the different problems
*/
function chooseQuestionType() {
const questionType = process.env.REACT_APP_PROBLEM_SET;

if(questionTypeList.includes(questionType!)) {
return import(`./${questionType}/problems.js`)
} else{
throw Error('The env REACT_APP_PROBLEM_SET is incorrect or not set')
}
}

export default chooseQuestionType;
6 changes: 4 additions & 2 deletions src/utils/getCategoryList.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import problems from "../problems/problems";
import chooseQuestionType from "../problems";

const {problems} = await chooseQuestionType()

// TODO: since mutation and haystack aren't considered categories,
// the array this function returns doesn't contain them. if the issue
// of the problem type/category nesting is resolved, this may not be a problem anymore.
export function getCategoryList() {
const categories = new Set<string>();

problems.forEach((p) => {
problems.forEach((p: any) => {
categories.add(p.meta.category);
});

Expand Down
4 changes: 3 additions & 1 deletion src/utils/getCompletedProblems.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import problems from "../problems/problems";
import chooseQuestionType from "../problems";
import { Progress, Submission } from "../types";

const {problems} = await chooseQuestionType()

interface CompletedByCategory {
problems: {
title: string;
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2022",
"lib": [
"dom",
"dom.iterable",
Expand Down
Loading