aboutsummaryrefslogtreecommitdiff
path: root/src/group-fetch.ts
blob: de0991d09eb072e2a5a239603d5f15685fdab246 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { fetchStudents } from "./student-ENV.ts";
import { Group, buildGroups, _groups } from "./group.ts";

/**
 * Fetch all Groups and return them as a map.
 */
async function fetchGroups() {
	if (_groups.size) {
		return _groups;
	}

	// Fetch all students and build the groups from them
	const students = await fetchStudents();
	buildGroups(students);
	return _groups;
}

export { Group, buildGroups, fetchGroups };