Skip to content

Commit a05af95

Browse files
wip: snapshot summary generator
1 parent aca0abe commit a05af95

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

tests/accuracy/sdk/accuracy-snapshot-storage/mdb-snapshot-storage.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ export class MongoDBSnapshotStorage implements AccuracySnapshotStorage {
4949
await this.snapshotCollection.insertOne(snapshotWithMeta);
5050
}
5151

52-
async getLastRunIdForCommit(commit: string): Promise<string | undefined> {
52+
async getLatestSnapshotsForCommit(commit: string): Promise<AccuracySnapshotEntry[]> {
53+
const latestRunId = await this.getLastRunIdForCommit(commit);
54+
return latestRunId ? this.getSnapshotEntriesForRunId(latestRunId) : [];
55+
}
56+
57+
private async getLastRunIdForCommit(commit: string): Promise<string | undefined> {
5358
const document = await this.snapshotCollection.findOne(
5459
{ commit: commit },
5560
{ sort: { createdOn: -1 }, projection: { accuracyRunId: 1 } }
@@ -58,7 +63,7 @@ export class MongoDBSnapshotStorage implements AccuracySnapshotStorage {
5863
return document?.accuracyRunId ? `${document?.accuracyRunId}` : undefined;
5964
}
6065

61-
async getSnapshotEntriesForRunId(accuracyRunId: string): Promise<AccuracySnapshotEntry[]> {
66+
private async getSnapshotEntriesForRunId(accuracyRunId: string): Promise<AccuracySnapshotEntry[]> {
6267
const snapshotEntries = await this.snapshotCollection.find({ accuracyRunId }).toArray();
6368
return AccuracySnapshotEntrySchema.array().parse(snapshotEntries);
6469
}

tests/accuracy/sdk/accuracy-snapshot-storage/snapshot-storage.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ export interface AccuracySnapshotStorage {
4343
>
4444
): Promise<void>;
4545

46-
getLastRunIdForCommit(commit: string): Promise<string | undefined>;
47-
48-
getSnapshotEntriesForRunId(accuracyRunId: string): Promise<AccuracySnapshotEntry[]>;
46+
getLatestSnapshotsForCommit(commit: string): Promise<AccuracySnapshotEntry[]>;
4947

5048
close(): Promise<void>;
5149
}

tests/accuracy/sdk/git-info.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ export async function getCommitSHA(): Promise<string | undefined> {
55
const lastCommit = commitLogs.latest;
66
return lastCommit?.hash;
77
}
8+
9+
export async function getMergeBase(targetBranch: string, workBranchOrCommit: string): Promise<string> {
10+
const result = await simpleGit().raw(["merge-base", targetBranch, workBranchOrCommit]);
11+
return result.trim();
12+
}

0 commit comments

Comments
 (0)