|
| 1 | +import path from "path"; |
1 | 2 | import { AccuracyTestConfig, describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
|
2 | 3 | import { Matcher } from "./sdk/matcher.js";
|
| 4 | +import * as fs from "fs"; |
| 5 | + |
| 6 | +function getDocumentCounts(): Array<{ severity: number; tickets: number }> { |
| 7 | + const ticketsPath = path.resolve(__dirname, "test-data-dumps", "support.tickets.json"); |
| 8 | + |
| 9 | + const ticketsData = JSON.parse(fs.readFileSync(ticketsPath, "utf-8")) as { severity: number }[]; |
| 10 | + |
| 11 | + const counts: Record<number, number> = {}; |
| 12 | + |
| 13 | + for (const ticket of ticketsData) { |
| 14 | + counts[ticket.severity] = (counts[ticket.severity] || 0) + 1; |
| 15 | + } |
| 16 | + |
| 17 | + return Object.entries(counts) |
| 18 | + |
| 19 | + .map(([severity, tickets]) => ({ severity: Number(severity), tickets })); |
| 20 | +} |
3 | 21 |
|
4 | 22 | const describeAggregationWithUpdate = (): AccuracyTestConfig => {
|
5 | 23 | // This test is validating the model can execute an aggregation and also access the data
|
6 | 24 | // from the result and then use it to update another collection.
|
7 |
| - const documentCounts = [ |
8 |
| - { severity: 1, tickets: 3 }, |
9 |
| - { severity: 2, tickets: 4 }, |
10 |
| - { severity: 3, tickets: 3 }, |
11 |
| - ]; |
| 25 | + const documentCounts = getDocumentCounts(); |
12 | 26 |
|
13 | 27 | return {
|
14 | 28 | prompt: "Create an aggregation that groups the support tickets from the 'support.tickets' namespace by their severity. Then for each group update the 'statistics' collection in the 'support' database and increase the count of tickets filed for that severity level. If there's no document corresponding to the severity level, you should create it. The final state should look something similar to { severity: 2, tickets: 5 }.",
|
|
0 commit comments