(programId, isRefresh = false, options = {})
| 103 | export async function getProgram(programId, isRefresh = false, options = {}) { |
| 104 | /* |
| 105 | * Get the program (without description) from the server or local storage by programId |
| 106 | * @param programId [String]: programId |
| 107 | * @param isRefresh [Boolean]: whether to refresh the data |
| 108 | * @return: program (without description) |
| 109 | */ |
| 110 | const programs = await getPrograms(isRefresh, {}, "cs_rank", options); |
| 111 | const univName = programId.split('@')[1] |
| 112 | if (!programs[univName]) { |
| 113 | throw new Response("", { |
| 114 | status: 404, |
| 115 | statusText: "Program not found", |
| 116 | } |
| 117 | ); |
| 118 | } |
| 119 | const program = programs[univName].find(currentProgram => currentProgram.ProgramID === programId); |
| 120 | if (!program) { |
| 121 | throw new Response("", { |
| 122 | status: 404, |
| 123 | statusText: "Program not found", |
| 124 | }); |
| 125 | } |
| 126 | return program; |
| 127 | } |
| 128 | |
| 129 | export async function getProgramDesc(programId, isRefresh = false, {priority = FOREGROUND_PRIORITY} = {}) { |
| 130 | /* |
| 131 | * Get the description of the program from the server or local storage by programId |
| 132 | * @param programId [String]: programId |
no test coverage detected