aboutsummaryrefslogtreecommitdiff
path: root/src/group-fetch.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/group-fetch.ts')
-rw-r--r--src/group-fetch.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/group-fetch.ts b/src/group-fetch.ts
new file mode 100644
index 0000000..de0991d
--- /dev/null
+++ b/src/group-fetch.ts
@@ -0,0 +1,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 };