Skip to content

Commit f9074fb

Browse files
authored
refactor: test events phase 1 (@Miodec) (#8021)
Consolidate all data into one array of events, derive all stats from this array. Phase 1 runs the new system in shadow mode, comparing to the original and sending mismatches to the backend. Phase 2 will fully replace the system.
1 parent 033c7cf commit f9074fb

26 files changed

Lines changed: 3663 additions & 19 deletions

File tree

backend/src/api/controllers/result.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
GetResultsResponse,
4444
UpdateResultTagsRequest,
4545
UpdateResultTagsResponse,
46+
ReportCompletedEventMismatchRequest,
4647
} from "@monkeytype/contracts/results";
4748
import {
4849
CompletedEvent,
@@ -184,6 +185,20 @@ export async function updateTags(
184185
});
185186
}
186187

188+
export async function reportCompletedEventMismatch(
189+
req: MonkeyRequest<undefined, ReportCompletedEventMismatchRequest>,
190+
): Promise<MonkeyResponse> {
191+
const { uid } = req.ctx.decodedToken;
192+
const { notMatching } = req.body;
193+
// Logger.warning(
194+
// `Completed event mismatch for uid ${uid}: ${notMatching.join(", ")}`,
195+
// );
196+
// Logger.warning(`Old CE: ${JSON.stringify(ce)}`);
197+
// Logger.warning(`New CE: ${JSON.stringify(ce2)}`);
198+
void addLog("completed_event_mismatch", { notMatching }, uid);
199+
return new MonkeyResponse("Mismatch reported", null);
200+
}
201+
187202
export async function addResult(
188203
req: MonkeyRequest<undefined, AddResultRequest>,
189204
): Promise<AddResultResponse> {

backend/src/api/routes/results.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export default s.router(resultsContract, {
1717
updateTags: {
1818
handler: async (r) => callController(ResultController.updateTags)(r),
1919
},
20+
reportCompletedEventMismatch: {
21+
handler: async (r) =>
22+
callController(ResultController.reportCompletedEventMismatch)(r),
23+
},
2024
deleteAll: {
2125
handler: async (r) => callController(ResultController.deleteAll)(r),
2226
},

0 commit comments

Comments
 (0)