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