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
5 changes: 3 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pnpm install
pnpm bootstrap # once: writes .env from .env.example with generated secrets
pnpm infra:up # MySQL, Keycloak, Mailpit, Adminer, Grafana LGTM (Docker must be running)
pnpm dev # backend :8080 + web app :3470 on the host
pnpm seed # demo college and sign-in accounts, with the stack running (scripts/PRESENT.md)
pnpm reset # wipe all local volumes, keep .env
pnpm apps:up / apps:down # run both apps as containers instead (stop `pnpm dev` first)
```
Expand Down Expand Up @@ -65,8 +66,8 @@ pnpm --filter kibootia-frontend build
pnpm --filter kibootia-frontend test:e2e # Playwright; needs the full stack running
```

**Known baseline:** 15 Vitest tests in `tests/unit/{avatar,import-screen,note-attachment}.test.tsx` already fail before
any Timetia change. Any other failure is a regression.
**Baseline:** all Vitest tests pass. Run them from PowerShell: from Git Bash on this machine the jest-dom matchers fail
in multi-file runs. Any failure is a regression.

### After any API change (in this order; CI fails if either generated file is stale)

Expand Down
58 changes: 58 additions & 0 deletions HANDOVER-PHASE-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Handover: Phase 3 (issues, notifications, setup, finish)

Branch `dog`. Written 2026-11-25. Spec: `frontend/docs/phase-3.md`. Nothing is committed.

## Done

- **Backend**: names on issues; notifications say who, what kind, which lecture and whether the person may open the ticket;
`PUT /faculties/{id}/account`; `reference.AcademicDirectory.batchCodes`, `rescheduling.TicketSummaries`.
- **Frontend**: notifications and issues finished (tabs, mention, link ticket, close rules); new Campus and Timetables
screens under Administration; component tests for tickets, issues, notifications and setup; one end-to-end test.
- **Docs**: `scripts/DEMO.md` is a click-through; deferred features are in the module's `open-questions.md`.

## Bugs found and fixed

- A student's notification led to "not found". Fixed.
- The rule in `domain.md` for that was also wrong: a batch representative who is also a student was still sent to a theory
ticket they cannot open (404). The server now says (`ticketVisible`), and `domain.md` is updated.
- Administration pages scrolled sideways on a phone.
- The whole app was drawn in a serif font (a CSS variable that referred to itself).

## Different from the spec

- The demo accounts are those of `pnpm seed` (`stu.cse-a1`, `cr.cse-a`, ...); `demo-cr`, `demo-br`, `demo-student` were not added.
- The 15 tests recorded as failing before Timetia now pass without any change.

## What was run

- Backend full `verify`: 250 unit + 594 integration tests, no failures. The `ticketVisible` change came **after** this run;
for it only `NotificationApiIT`, `OpenApiContractIT` (13 tests), `ArchitectureTest` and `ModularityTest` (14) were run.
- Frontend: typecheck, lint (0 errors, 2 older warnings), 353 unit tests, production build.
- Live stack: `pnpm seed`; `tests/e2e/rescheduling.spec.ts`; a one-off scripted walk of campus create/rename/delete, a draft
timetable with a clash, the issue flow, student notification links, and 400 px width. The end-to-end test and the walk ran
against the production web server (`next build` + `next start`).

## Checked later the same day (scripted browser against `pnpm dev`)

All passed: cancel, substitute, exchange, permanent change, extra lecture, reject then edit, escalate, apply and revert,
a blocked clashing move, an HOD acting for a teacher, a student opening a ticket page, the ticket page and raise dialog at
400 px, publishing a timetable, and removing and restoring a faculty account link. In a real Chrome the signed-out home page
did not reload itself under `pnpm dev`.

## Not done or not checked

- Parts of the Phase 3 exit check in a browser: the audit log entries, the HOD's issue list, what a class representative and
a batch representative may not do or see, and newly published lectures appearing (the test publish created none). Backend
tests cover the visibility rules.
- The older Playwright specs (sign-in, identity, notes, ...) were not run.
- `pnpm dev` once reloaded the home page endlessly, so `pnpm seed` failed. It has not happened on later starts and the cause
is unknown. If it does, restart `pnpm dev`; `pnpm apps:up` runs the apps without live reload.
- Deferred features: `timetia-docs/modules/lecture-rescheduling/open-questions.md`.

## Local data

- Test runs added tickets (applied changes were reverted, drafts withdrawn) and two closed issues named "Walkthrough ...".
- A cancelled extra OOP lecture sits on Saturday 12 December, 18:00.
- ME-B has an extra published version from Sunday 13 December. It creates no lectures.
- The seeded term runs from 16 November to 13 December. To present after that, `pnpm reset` (deletes all local data) and
seed again, which also clears the items above.
164 changes: 162 additions & 2 deletions backend/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,9 @@
},
"IssueResponse" : {
"properties" : {
"batchCode" : {
"type" : [ "string", "null" ]
},
"batchId" : {
"format" : "uuid",
"type" : [ "string", "null" ]
Expand All @@ -863,6 +866,9 @@
"format" : "date-time",
"type" : [ "string", "null" ]
},
"closedByName" : {
"type" : [ "string", "null" ]
},
"closedByUserId" : {
"format" : "uuid",
"type" : [ "string", "null" ]
Expand All @@ -878,6 +884,9 @@
"description" : {
"type" : [ "string", "null" ]
},
"divisionCode" : {
"type" : [ "string", "null" ]
},
"divisionId" : {
"format" : "uuid",
"type" : "string"
Expand All @@ -893,13 +902,22 @@
},
"type" : "array"
},
"mentionedFaculty" : {
"items" : {
"$ref" : "#/components/schemas/MentionedFaculty"
},
"type" : "array"
},
"mentionedFacultyIds" : {
"items" : {
"format" : "uuid",
"type" : "string"
},
"type" : "array"
},
"openerName" : {
"type" : [ "string", "null" ]
},
"openerUserId" : {
"format" : "uuid",
"type" : "string"
Expand All @@ -924,7 +942,7 @@
"type" : "integer"
}
},
"required" : [ "createdAt", "departmentId", "divisionId", "id", "linkedTicketIds", "mentionedFacultyIds", "openerUserId", "sessionType", "status", "title", "updatedAt", "version" ],
"required" : [ "createdAt", "departmentId", "divisionId", "id", "linkedTicketIds", "mentionedFaculty", "mentionedFacultyIds", "openerUserId", "sessionType", "status", "title", "updatedAt", "version" ],
"type" : "object"
},
"LectureSummaryResponse" : {
Expand Down Expand Up @@ -997,6 +1015,21 @@
"required" : [ "accountCreated", "email", "line", "outcome", "role", "scope" ],
"type" : "object"
},
"LinkAccountRequest" : {
"properties" : {
"userId" : {
"format" : "uuid",
"type" : [ "string", "null" ]
},
"version" : {
"format" : "int64",
"minimum" : 0,
"type" : "integer"
}
},
"required" : [ "version" ],
"type" : "object"
},
"LinkRequest" : {
"properties" : {
"ticketId" : {
Expand Down Expand Up @@ -1184,6 +1217,19 @@
"required" : [ "facultyId" ],
"type" : "object"
},
"MentionedFaculty" : {
"properties" : {
"id" : {
"format" : "uuid",
"type" : "string"
},
"name" : {
"type" : [ "string", "null" ]
}
},
"required" : [ "id" ],
"type" : "object"
},
"MyAssignmentResponse" : {
"properties" : {
"batchCode" : {
Expand Down Expand Up @@ -1283,6 +1329,10 @@
},
"NotificationResponse" : {
"properties" : {
"actorName" : {
"description" : "The name of who caused it.",
"type" : [ "string", "null" ]
},
"actorUserId" : {
"description" : "Who caused it.",
"format" : "uuid",
Expand All @@ -1300,6 +1350,11 @@
"format" : "uuid",
"type" : [ "string", "null" ]
},
"lectureId" : {
"description" : "The lecture the ticket is about.",
"format" : "uuid",
"type" : [ "string", "null" ]
},
"readAt" : {
"format" : "date-time",
"type" : [ "string", "null" ]
Expand All @@ -1308,12 +1363,20 @@
"format" : "uuid",
"type" : [ "string", "null" ]
},
"ticketType" : {
"description" : "The kind of ticket it is about.",
"type" : [ "string", "null" ]
},
"ticketVisible" : {
"description" : "Whether the caller may open the ticket.",
"type" : "boolean"
},
"type" : {
"enum" : [ "REVIEW_REQUESTED", "REVIEW_APPROVED", "REVIEW_REJECTED", "TICKET_APPLIED", "TICKET_CONFLICTED", "TICKET_EDITED", "TICKET_WITHDRAWN", "TICKET_REVERTED", "ISSUE_MENTION" ],
"type" : "string"
}
},
"required" : [ "createdAt", "id", "type" ],
"required" : [ "createdAt", "id", "ticketVisible", "type" ],
"type" : "object"
},
"PageInfo" : {
Expand Down Expand Up @@ -5170,6 +5233,103 @@
"tags" : [ "faculties" ]
}
},
"/api/v1/faculties/{id}/account" : {
"put" : {
"operationId" : "facultiesLinkAccount",
"parameters" : [ {
"in" : "path",
"name" : "id",
"required" : true,
"schema" : {
"format" : "uuid",
"type" : "string"
}
} ],
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/LinkAccountRequest"
}
}
},
"required" : true
},
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/FacultyResponse"
}
}
},
"description" : "OK"
},
"400" : {
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
},
"description" : "The request is malformed or fails validation; see `errors`."
},
"401" : {
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
},
"description" : "No valid bearer token."
},
"403" : {
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
},
"description" : "The caller may not do this."
},
"404" : {
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
},
"description" : "There is no such record, or the caller may not see it."
},
"409" : {
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
},
"description" : "The record changed meanwhile, or the request clashes with its state."
},
"500" : {
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
},
"description" : "An unexpected failure; quote the `traceId`."
}
},
"tags" : [ "faculties" ]
}
},
"/api/v1/failed-events" : {
"get" : {
"operationId" : "failedEventsList",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.kibootia.backend.issues.application;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kibootia.backend.platform.authorization.NoAuthorization;
import com.kibootia.backend.platform.directory.UserDirectory;
import com.kibootia.backend.platform.directory.UserSummary;
import com.kibootia.backend.reference.AcademicDirectory;

/**
* Looks up the names behind the ids of issues so that the screens never have to: the people, the teachers mentioned and the
* place. People, teachers and batches are one lookup each for the whole page; divisions are read one by one, once for each
* distinct division, of which a page holds very few.
*/
@Service
public class IssueNameService {

private final UserDirectory users;

private final AcademicDirectory directory;

IssueNameService(UserDirectory users, AcademicDirectory directory) {
this.users = users;
this.directory = directory;
}

/** @param details issues the caller has already been allowed to see */
@Transactional(readOnly = true)
@NoAuthorization("adds names to issues the caller has already been allowed to see")
public IssueNames namesFor(Collection<IssueDetail> details) {
Set<UUID> userIds = new HashSet<>();
Set<UUID> divisionIds = new HashSet<>();
Set<UUID> batchIds = new HashSet<>();
Set<UUID> facultyIds = new HashSet<>();
for (IssueDetail detail : details) {
Issue issue = detail.issue();
userIds.add(issue.openerUserId());
if (issue.closedByUserId() != null) {
userIds.add(issue.closedByUserId());
}
divisionIds.add(issue.divisionId());
if (issue.batchId() != null) {
batchIds.add(issue.batchId());
}
facultyIds.addAll(detail.mentionedFacultyIds());
}
Map<UUID, String> userNames = this.users.find(userIds)
.values()
.stream()
.collect(Collectors.toMap(UserSummary::id, UserSummary::displayName, (first, second) -> first));
Map<UUID, String> divisionCodes = new HashMap<>();
divisionIds.forEach((id) -> this.directory.division(id)
.ifPresent((division) -> divisionCodes.put(id, division.code())));
return new IssueNames(userNames, divisionCodes, this.directory.batchCodes(batchIds),
this.directory.faculties(facultyIds));
}

}
Loading
Loading