@knpkv/codecommit-core 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AwsClient/AwsClientGated.d.ts +27 -0
- package/dist/AwsClient/AwsClientGated.d.ts.map +1 -0
- package/dist/AwsClient/AwsClientGated.js +105 -0
- package/dist/AwsClient/AwsClientGated.js.map +1 -0
- package/dist/AwsClient/getDifferences.d.ts +16 -0
- package/dist/AwsClient/getDifferences.d.ts.map +1 -0
- package/dist/AwsClient/getDifferences.js +22 -0
- package/dist/AwsClient/getDifferences.js.map +1 -0
- package/dist/AwsClient/getPullRequest.d.ts.map +1 -1
- package/dist/AwsClient/getPullRequest.js +26 -5
- package/dist/AwsClient/getPullRequest.js.map +1 -1
- package/dist/AwsClient/getPullRequests.d.ts.map +1 -1
- package/dist/AwsClient/getPullRequests.js +29 -11
- package/dist/AwsClient/getPullRequests.js.map +1 -1
- package/dist/AwsClient/index.d.ts +21 -13
- package/dist/AwsClient/index.d.ts.map +1 -1
- package/dist/AwsClient/index.js +3 -1
- package/dist/AwsClient/index.js.map +1 -1
- package/dist/AwsClient/internal.d.ts +23 -0
- package/dist/AwsClient/internal.d.ts.map +1 -1
- package/dist/AwsClient/internal.js +4 -1
- package/dist/AwsClient/internal.js.map +1 -1
- package/dist/CacheService/Database.d.ts.map +1 -1
- package/dist/CacheService/Database.js +13 -1
- package/dist/CacheService/Database.js.map +1 -1
- package/dist/CacheService/EventsHub.d.ts +44 -4
- package/dist/CacheService/EventsHub.d.ts.map +1 -1
- package/dist/CacheService/EventsHub.js.map +1 -1
- package/dist/CacheService/index.d.ts +3 -2
- package/dist/CacheService/index.d.ts.map +1 -1
- package/dist/CacheService/index.js +2 -1
- package/dist/CacheService/index.js.map +1 -1
- package/dist/CacheService/migrations/0007_stats_columns.d.ts +5 -0
- package/dist/CacheService/migrations/0007_stats_columns.d.ts.map +1 -0
- package/dist/CacheService/migrations/0007_stats_columns.js +13 -0
- package/dist/CacheService/migrations/0007_stats_columns.js.map +1 -0
- package/dist/CacheService/migrations/0008_merged_by.d.ts +5 -0
- package/dist/CacheService/migrations/0008_merged_by.d.ts.map +1 -0
- package/dist/CacheService/migrations/0008_merged_by.js +4 -0
- package/dist/CacheService/migrations/0008_merged_by.js.map +1 -0
- package/dist/CacheService/migrations/0009_approved_by.d.ts +5 -0
- package/dist/CacheService/migrations/0009_approved_by.d.ts.map +1 -0
- package/dist/CacheService/migrations/0009_approved_by.js +4 -0
- package/dist/CacheService/migrations/0009_approved_by.js.map +1 -0
- package/dist/CacheService/migrations/0010_commented_by.d.ts +5 -0
- package/dist/CacheService/migrations/0010_commented_by.d.ts.map +1 -0
- package/dist/CacheService/migrations/0010_commented_by.js +4 -0
- package/dist/CacheService/migrations/0010_commented_by.js.map +1 -0
- package/dist/CacheService/migrations/0011_audit_log.d.ts +5 -0
- package/dist/CacheService/migrations/0011_audit_log.d.ts.map +1 -0
- package/dist/CacheService/migrations/0011_audit_log.js +19 -0
- package/dist/CacheService/migrations/0011_audit_log.js.map +1 -0
- package/dist/CacheService/migrations/0012_audit_log_indexes.d.ts +5 -0
- package/dist/CacheService/migrations/0012_audit_log_indexes.d.ts.map +1 -0
- package/dist/CacheService/migrations/0012_audit_log_indexes.js +7 -0
- package/dist/CacheService/migrations/0012_audit_log_indexes.js.map +1 -0
- package/dist/CacheService/repos/PullRequestRepo/index.d.ts +132 -0
- package/dist/CacheService/repos/PullRequestRepo/index.d.ts.map +1 -0
- package/dist/CacheService/repos/PullRequestRepo/index.js +35 -0
- package/dist/CacheService/repos/PullRequestRepo/index.js.map +1 -0
- package/dist/CacheService/repos/PullRequestRepo/internal.d.ts +72 -0
- package/dist/CacheService/repos/PullRequestRepo/internal.d.ts.map +1 -0
- package/dist/CacheService/repos/PullRequestRepo/internal.js +69 -0
- package/dist/CacheService/repos/PullRequestRepo/internal.js.map +1 -0
- package/dist/CacheService/repos/PullRequestRepo/mutations.d.ts +24 -0
- package/dist/CacheService/repos/PullRequestRepo/mutations.d.ts.map +1 -0
- package/dist/CacheService/repos/PullRequestRepo/mutations.js +94 -0
- package/dist/CacheService/repos/PullRequestRepo/mutations.js.map +1 -0
- package/dist/CacheService/repos/PullRequestRepo/queries.d.ts +113 -0
- package/dist/CacheService/repos/PullRequestRepo/queries.d.ts.map +1 -0
- package/dist/CacheService/repos/PullRequestRepo/queries.js +89 -0
- package/dist/CacheService/repos/PullRequestRepo/queries.js.map +1 -0
- package/dist/CacheService/repos/StatsRepo/index.d.ts +93 -0
- package/dist/CacheService/repos/StatsRepo/index.d.ts.map +1 -0
- package/dist/CacheService/repos/StatsRepo/index.js +41 -0
- package/dist/CacheService/repos/StatsRepo/index.js.map +1 -0
- package/dist/CacheService/repos/StatsRepo/internal.d.ts +120 -0
- package/dist/CacheService/repos/StatsRepo/internal.d.ts.map +1 -0
- package/dist/CacheService/repos/StatsRepo/internal.js +34 -0
- package/dist/CacheService/repos/StatsRepo/internal.js.map +1 -0
- package/dist/CacheService/repos/StatsRepo/queries.d.ts +42 -0
- package/dist/CacheService/repos/StatsRepo/queries.d.ts.map +1 -0
- package/dist/CacheService/repos/StatsRepo/queries.js +182 -0
- package/dist/CacheService/repos/StatsRepo/queries.js.map +1 -0
- package/dist/CacheService/repos/StatsRepo/reviewerData.d.ts +47 -0
- package/dist/CacheService/repos/StatsRepo/reviewerData.d.ts.map +1 -0
- package/dist/CacheService/repos/StatsRepo/reviewerData.js +172 -0
- package/dist/CacheService/repos/StatsRepo/reviewerData.js.map +1 -0
- package/dist/DateUtils.d.ts +28 -0
- package/dist/DateUtils.d.ts.map +1 -1
- package/dist/DateUtils.js +69 -1
- package/dist/DateUtils.js.map +1 -1
- package/dist/Domain.d.ts +13 -3
- package/dist/Domain.d.ts.map +1 -1
- package/dist/Domain.js +6 -5
- package/dist/Domain.js.map +1 -1
- package/dist/Errors.d.ts +14 -1
- package/dist/Errors.d.ts.map +1 -1
- package/dist/Errors.js +10 -0
- package/dist/Errors.js.map +1 -1
- package/dist/PRService/index.d.ts +3 -3
- package/dist/PRService/index.d.ts.map +1 -1
- package/dist/PRService/index.js +1 -1
- package/dist/PRService/index.js.map +1 -1
- package/dist/PRService/internal.d.ts +24 -2
- package/dist/PRService/internal.d.ts.map +1 -1
- package/dist/PRService/internal.js +23 -8
- package/dist/PRService/internal.js.map +1 -1
- package/dist/PRService/refresh.d.ts +1 -1
- package/dist/PRService/refresh.d.ts.map +1 -1
- package/dist/PRService/refresh.js +2 -0
- package/dist/PRService/refresh.js.map +1 -1
- package/dist/PRService/refreshDiffs.d.ts +16 -0
- package/dist/PRService/refreshDiffs.d.ts.map +1 -0
- package/dist/PRService/refreshDiffs.js +54 -0
- package/dist/PRService/refreshDiffs.js.map +1 -0
- package/dist/PRService/refreshEnrich.d.ts +1 -1
- package/dist/PRService/refreshEnrich.d.ts.map +1 -1
- package/dist/PRService/refreshEnrich.js +3 -1
- package/dist/PRService/refreshEnrich.js.map +1 -1
- package/dist/PRService/refreshFetch.d.ts +1 -1
- package/dist/PRService/refreshFetch.d.ts.map +1 -1
- package/dist/PRService/refreshFetch.js +12 -3
- package/dist/PRService/refreshFetch.js.map +1 -1
- package/dist/PRService/refreshHistory.d.ts +19 -0
- package/dist/PRService/refreshHistory.d.ts.map +1 -0
- package/dist/PRService/refreshHistory.js +110 -0
- package/dist/PRService/refreshHistory.js.map +1 -0
- package/dist/PRService/refreshResolve.d.ts +1 -1
- package/dist/PRService/refreshResolve.d.ts.map +1 -1
- package/dist/PRService/refreshResolve.js +1 -1
- package/dist/PRService/refreshResolve.js.map +1 -1
- package/dist/PRService/refreshScore.d.ts +1 -1
- package/dist/PRService/refreshScore.d.ts.map +1 -1
- package/dist/PRService/refreshScore.js +1 -1
- package/dist/PRService/refreshScore.js.map +1 -1
- package/dist/PRService/refreshSinglePR.d.ts +1 -1
- package/dist/PRService/refreshSinglePR.d.ts.map +1 -1
- package/dist/PRService/refreshSinglePR.js +4 -3
- package/dist/PRService/refreshSinglePR.js.map +1 -1
- package/dist/PermissionService/AuditLog.d.ts +62 -0
- package/dist/PermissionService/AuditLog.d.ts.map +1 -0
- package/dist/PermissionService/AuditLog.js +113 -0
- package/dist/PermissionService/AuditLog.js.map +1 -0
- package/dist/PermissionService/PermissionGate.d.ts +47 -0
- package/dist/PermissionService/PermissionGate.d.ts.map +1 -0
- package/dist/PermissionService/PermissionGate.js +14 -0
- package/dist/PermissionService/PermissionGate.js.map +1 -0
- package/dist/PermissionService/PermissionGateLive.d.ts +41 -0
- package/dist/PermissionService/PermissionGateLive.d.ts.map +1 -0
- package/dist/PermissionService/PermissionGateLive.js +83 -0
- package/dist/PermissionService/PermissionGateLive.js.map +1 -0
- package/dist/PermissionService/index.d.ts +39 -0
- package/dist/PermissionService/index.d.ts.map +1 -0
- package/dist/PermissionService/index.js +87 -0
- package/dist/PermissionService/index.js.map +1 -0
- package/dist/PermissionService/operations.d.ts +40 -0
- package/dist/PermissionService/operations.d.ts.map +1 -0
- package/dist/PermissionService/operations.js +38 -0
- package/dist/PermissionService/operations.js.map +1 -0
- package/dist/StatsService/WeeklyStats.d.ts +174 -0
- package/dist/StatsService/WeeklyStats.d.ts.map +1 -0
- package/dist/StatsService/WeeklyStats.js +110 -0
- package/dist/StatsService/WeeklyStats.js.map +1 -0
- package/dist/StatsService/index.d.ts +45 -0
- package/dist/StatsService/index.d.ts.map +1 -0
- package/dist/StatsService/index.js +145 -0
- package/dist/StatsService/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/CacheService/repos/PullRequestRepo.d.ts +0 -112
- package/dist/CacheService/repos/PullRequestRepo.d.ts.map +0 -1
- package/dist/CacheService/repos/PullRequestRepo.js +0 -146
- package/dist/CacheService/repos/PullRequestRepo.js.map +0 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module PullRequestRepo/internal
|
|
3
|
+
*
|
|
4
|
+
* Schemas, types, and helpers shared across the PullRequestRepo modules.
|
|
5
|
+
*
|
|
6
|
+
* @category CacheService
|
|
7
|
+
*/
|
|
8
|
+
import * as Model from "@effect/sql/Model";
|
|
9
|
+
import { Effect, Schema } from "effect";
|
|
10
|
+
import { CacheError } from "../../CacheError.js";
|
|
11
|
+
/** DB column `TEXT` (comma-separated) <-> `readonly string[]` */
|
|
12
|
+
export declare const CommaSeparatedArray: Schema.transform<Schema.NullOr<typeof Schema.String>, Schema.Array$<typeof Schema.String>>;
|
|
13
|
+
export declare const CachedPullRequest: Schema.Struct<{
|
|
14
|
+
id: Schema.brand<typeof Schema.String, "PullRequestId">;
|
|
15
|
+
awsAccountId: typeof Schema.String;
|
|
16
|
+
accountProfile: Schema.brand<typeof Schema.String, "AwsProfileName">;
|
|
17
|
+
accountRegion: Schema.brand<typeof Schema.String, "AwsRegion">;
|
|
18
|
+
title: typeof Schema.String;
|
|
19
|
+
description: Schema.NullOr<typeof Schema.String>;
|
|
20
|
+
author: typeof Schema.String;
|
|
21
|
+
repositoryName: Schema.brand<typeof Schema.String, "RepositoryName">;
|
|
22
|
+
creationDate: typeof Schema.DateFromString;
|
|
23
|
+
lastModifiedDate: typeof Schema.DateFromString;
|
|
24
|
+
status: Schema.Literal<["OPEN", "CLOSED", "MERGED"]>;
|
|
25
|
+
sourceBranch: typeof Schema.String;
|
|
26
|
+
destinationBranch: typeof Schema.String;
|
|
27
|
+
isMergeable: typeof Model.BooleanFromNumber;
|
|
28
|
+
isApproved: typeof Model.BooleanFromNumber;
|
|
29
|
+
commentCount: Schema.NullOr<typeof Schema.Number>;
|
|
30
|
+
healthScore: Schema.NullOr<typeof Schema.Number>;
|
|
31
|
+
link: typeof Schema.String;
|
|
32
|
+
fetchedAt: typeof Schema.String;
|
|
33
|
+
filesAdded: Schema.NullOr<typeof Schema.Number>;
|
|
34
|
+
filesModified: Schema.NullOr<typeof Schema.Number>;
|
|
35
|
+
filesDeleted: Schema.NullOr<typeof Schema.Number>;
|
|
36
|
+
closedAt: Schema.NullOr<typeof Schema.String>;
|
|
37
|
+
mergedBy: Schema.NullOr<typeof Schema.String>;
|
|
38
|
+
approvedBy: Schema.transform<Schema.NullOr<typeof Schema.String>, Schema.Array$<typeof Schema.String>>;
|
|
39
|
+
commentedBy: Schema.transform<Schema.NullOr<typeof Schema.String>, Schema.Array$<typeof Schema.String>>;
|
|
40
|
+
}>;
|
|
41
|
+
export type CachedPullRequest = typeof CachedPullRequest.Type;
|
|
42
|
+
export interface SearchResult {
|
|
43
|
+
readonly items: ReadonlyArray<CachedPullRequest>;
|
|
44
|
+
readonly total: number;
|
|
45
|
+
readonly hasMore: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare const UpsertInput: Schema.Struct<{
|
|
48
|
+
id: typeof Schema.String;
|
|
49
|
+
awsAccountId: typeof Schema.String;
|
|
50
|
+
accountProfile: typeof Schema.String;
|
|
51
|
+
accountRegion: typeof Schema.String;
|
|
52
|
+
title: typeof Schema.String;
|
|
53
|
+
description: Schema.NullOr<typeof Schema.String>;
|
|
54
|
+
author: typeof Schema.String;
|
|
55
|
+
repositoryName: typeof Schema.String;
|
|
56
|
+
creationDate: typeof Schema.String;
|
|
57
|
+
lastModifiedDate: typeof Schema.String;
|
|
58
|
+
status: typeof Schema.String;
|
|
59
|
+
sourceBranch: typeof Schema.String;
|
|
60
|
+
destinationBranch: typeof Schema.String;
|
|
61
|
+
isMergeable: typeof Schema.Number;
|
|
62
|
+
isApproved: typeof Schema.Number;
|
|
63
|
+
commentCount: Schema.NullOr<typeof Schema.Number>;
|
|
64
|
+
link: typeof Schema.String;
|
|
65
|
+
approvedBy: Schema.Array$<typeof Schema.String>;
|
|
66
|
+
}>;
|
|
67
|
+
export type UpsertInput = typeof UpsertInput.Type;
|
|
68
|
+
/** Wrap an Effect with CacheError mapping and a span. */
|
|
69
|
+
export declare const cacheError: (op: string) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, CacheError, Exclude<R, import("effect/Tracer").ParentSpan>>;
|
|
70
|
+
/** Join a string array for the approved_by TEXT column. */
|
|
71
|
+
export declare const joinApprovedBy: (arr: ReadonlyArray<string>) => string | null;
|
|
72
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../src/CacheService/repos/PullRequestRepo/internal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,4FAO/B,CAAA;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2B5B,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAA;AAE7D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAA;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAC1B;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;EAmBtB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA;AAEjD,yDAAyD;AACzD,eAAO,MAAM,UAAU,GAAI,IAAI,MAAM,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,iFAI/E,CAAA;AAEH,2DAA2D;AAC3D,eAAO,MAAM,cAAc,GAAI,KAAK,aAAa,CAAC,MAAM,CAAC,kBAA4C,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module PullRequestRepo/internal
|
|
3
|
+
*
|
|
4
|
+
* Schemas, types, and helpers shared across the PullRequestRepo modules.
|
|
5
|
+
*
|
|
6
|
+
* @category CacheService
|
|
7
|
+
*/
|
|
8
|
+
import * as Model from "@effect/sql/Model";
|
|
9
|
+
import { Effect, Schema } from "effect";
|
|
10
|
+
import { AwsProfileName, AwsRegion, PullRequestId, PullRequestStatus, RepositoryName } from "../../../Domain.js";
|
|
11
|
+
import { CacheError } from "../../CacheError.js";
|
|
12
|
+
/** DB column `TEXT` (comma-separated) <-> `readonly string[]` */
|
|
13
|
+
export const CommaSeparatedArray = Schema.transform(Schema.NullOr(Schema.String), Schema.Array(Schema.String), {
|
|
14
|
+
decode: (s) => (s ? s.split(",") : []),
|
|
15
|
+
encode: (arr) => (arr.length > 0 ? arr.join(",") : null)
|
|
16
|
+
});
|
|
17
|
+
export const CachedPullRequest = Schema.Struct({
|
|
18
|
+
id: PullRequestId,
|
|
19
|
+
awsAccountId: Schema.String,
|
|
20
|
+
accountProfile: AwsProfileName,
|
|
21
|
+
accountRegion: AwsRegion,
|
|
22
|
+
title: Schema.String,
|
|
23
|
+
description: Schema.NullOr(Schema.String),
|
|
24
|
+
author: Schema.String,
|
|
25
|
+
repositoryName: RepositoryName,
|
|
26
|
+
creationDate: Schema.DateFromString,
|
|
27
|
+
lastModifiedDate: Schema.DateFromString,
|
|
28
|
+
status: PullRequestStatus,
|
|
29
|
+
sourceBranch: Schema.String,
|
|
30
|
+
destinationBranch: Schema.String,
|
|
31
|
+
isMergeable: Model.BooleanFromNumber,
|
|
32
|
+
isApproved: Model.BooleanFromNumber,
|
|
33
|
+
commentCount: Schema.NullOr(Schema.Number),
|
|
34
|
+
healthScore: Schema.NullOr(Schema.Number),
|
|
35
|
+
link: Schema.String,
|
|
36
|
+
fetchedAt: Schema.String,
|
|
37
|
+
filesAdded: Schema.NullOr(Schema.Number),
|
|
38
|
+
filesModified: Schema.NullOr(Schema.Number),
|
|
39
|
+
filesDeleted: Schema.NullOr(Schema.Number),
|
|
40
|
+
closedAt: Schema.NullOr(Schema.String),
|
|
41
|
+
mergedBy: Schema.NullOr(Schema.String),
|
|
42
|
+
approvedBy: CommaSeparatedArray,
|
|
43
|
+
commentedBy: CommaSeparatedArray
|
|
44
|
+
});
|
|
45
|
+
export const UpsertInput = Schema.Struct({
|
|
46
|
+
id: Schema.String,
|
|
47
|
+
awsAccountId: Schema.String,
|
|
48
|
+
accountProfile: Schema.String,
|
|
49
|
+
accountRegion: Schema.String,
|
|
50
|
+
title: Schema.String,
|
|
51
|
+
description: Schema.NullOr(Schema.String),
|
|
52
|
+
author: Schema.String,
|
|
53
|
+
repositoryName: Schema.String,
|
|
54
|
+
creationDate: Schema.String,
|
|
55
|
+
lastModifiedDate: Schema.String,
|
|
56
|
+
status: Schema.String,
|
|
57
|
+
sourceBranch: Schema.String,
|
|
58
|
+
destinationBranch: Schema.String,
|
|
59
|
+
isMergeable: Schema.Number,
|
|
60
|
+
isApproved: Schema.Number,
|
|
61
|
+
commentCount: Schema.NullOr(Schema.Number),
|
|
62
|
+
link: Schema.String,
|
|
63
|
+
approvedBy: Schema.Array(Schema.String)
|
|
64
|
+
});
|
|
65
|
+
/** Wrap an Effect with CacheError mapping and a span. */
|
|
66
|
+
export const cacheError = (op) => (effect) => effect.pipe(Effect.mapError((cause) => new CacheError({ operation: `PullRequestRepo.${op}`, cause })), Effect.withSpan(`PullRequestRepo.${op}`, { captureStackTrace: false }));
|
|
67
|
+
/** Join a string array for the approved_by TEXT column. */
|
|
68
|
+
export const joinApprovedBy = (arr) => (arr.length > 0 ? arr.join(",") : null);
|
|
69
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../../src/CacheService/repos/PullRequestRepo/internal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;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CAAC,MAAM;IACrB,YAAY,EAAE,MAAM,CAAC,MAAM;IAC3B,iBAAiB,EAAE,MAAM,CAAC,MAAM;IAChC,WAAW,EAAE,MAAM,CAAC,MAAM;IAC1B,UAAU,EAAE,MAAM,CAAC,MAAM;IACzB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;CACxC,CAAC,CAAA;AAIF,yDAAyD;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,CAAU,MAA8B,EAAE,EAAE,CACpF,MAAM,CAAC,IAAI,CACT,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,EACzF,MAAM,CAAC,QAAQ,CAAC,mBAAmB,EAAE,EAAE,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CACvE,CAAA;AAEH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAA0B,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module PullRequestRepo/mutations
|
|
3
|
+
*
|
|
4
|
+
* SQL write operations. Each function takes `sql` and `publish` (change event)
|
|
5
|
+
* and returns the mutation implementations as an object.
|
|
6
|
+
*
|
|
7
|
+
* @category CacheService
|
|
8
|
+
*/
|
|
9
|
+
import type * as SqlClient from "@effect/sql/SqlClient";
|
|
10
|
+
import { Effect } from "effect";
|
|
11
|
+
import { UpsertInput } from "./internal.js";
|
|
12
|
+
export declare const mutations: (sql: SqlClient.SqlClient, publish: Effect.Effect<void>) => {
|
|
13
|
+
readonly upsert: (input: UpsertInput) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
|
|
14
|
+
readonly upsertMany: (prs: ReadonlyArray<UpsertInput>) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
|
|
15
|
+
readonly deleteStale: (olderThan: string) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
|
|
16
|
+
readonly deleteStaleOpen: (olderThan: string) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
|
|
17
|
+
readonly deleteOne: (awsAccountId: string, id: string) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
|
|
18
|
+
readonly updateDiffStats: (awsAccountId: string, id: string, filesAdded: number, filesModified: number, filesDeleted: number) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
|
|
19
|
+
readonly updateStatusAndClosedAt: (awsAccountId: string, id: string, status: string, closedAt: string, mergedBy?: string, approvedBy?: ReadonlyArray<string>) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
|
|
20
|
+
readonly updateCommentCount: (awsAccountId: string, id: string, count: number | null) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
|
|
21
|
+
readonly updateHealthScore: (awsAccountId: string, id: string, score: number) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
|
|
22
|
+
readonly refreshCommentedBy: () => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=mutations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../../../src/CacheService/repos/PullRequestRepo/mutations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,KAAK,SAAS,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAA;AAEvC,OAAO,EAA8B,WAAW,EAAE,MAAM,eAAe,CAAA;AAEvE,eAAO,MAAM,SAAS,GAAI,KAAK,SAAS,CAAC,SAAS,EAAE,SAAS,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;6BAgD5D,WAAW;+BAET,aAAa,CAAC,WAAW,CAAC;sCAMnB,MAAM;0CAGF,MAAM;uCAGT,MAAM,MAAM,MAAM;6CAQ5B,MAAM,MAChB,MAAM,cACE,MAAM,iBACH,MAAM,gBACP,MAAM;qDAUN,MAAM,MAChB,MAAM,UACF,MAAM,YACJ,MAAM,aACL,MAAM,eACJ,aAAa,CAAC,MAAM,CAAC;gDAaD,MAAM,MAAM,MAAM,SAAS,MAAM,GAAG,IAAI;+CAQzC,MAAM,MAAM,MAAM,SAAS,MAAM;;CAsCtE,CAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as SqlSchema from "@effect/sql/SqlSchema";
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
import { PRCommentLocationJson } from "../../../Domain.js";
|
|
4
|
+
import { cacheError, joinApprovedBy, UpsertInput } from "./internal.js";
|
|
5
|
+
export const mutations = (sql, publish) => {
|
|
6
|
+
const upsert_ = SqlSchema.void({
|
|
7
|
+
Request: UpsertInput,
|
|
8
|
+
execute: (req) => {
|
|
9
|
+
const approvedByStr = joinApprovedBy(req.approvedBy);
|
|
10
|
+
return sql `INSERT INTO pull_requests
|
|
11
|
+
(id, aws_account_id, account_profile, account_region, title, description,
|
|
12
|
+
author, repository_name, creation_date, last_modified_date, status,
|
|
13
|
+
source_branch, destination_branch, is_mergeable, is_approved,
|
|
14
|
+
comment_count, link, approved_by, fetched_at)
|
|
15
|
+
VALUES (${req.id}, ${req.awsAccountId}, ${req.accountProfile}, ${req.accountRegion},
|
|
16
|
+
${req.title}, ${req.description}, ${req.author}, ${req.repositoryName},
|
|
17
|
+
${req.creationDate}, ${req.lastModifiedDate}, ${req.status},
|
|
18
|
+
${req.sourceBranch}, ${req.destinationBranch}, ${req.isMergeable}, ${req.isApproved},
|
|
19
|
+
${req.commentCount}, ${req.link}, ${approvedByStr}, strftime('%Y-%m-%dT%H:%M:%SZ', 'now'))
|
|
20
|
+
ON CONFLICT (aws_account_id, id) DO UPDATE SET
|
|
21
|
+
account_profile = excluded.account_profile,
|
|
22
|
+
account_region = excluded.account_region,
|
|
23
|
+
title = excluded.title,
|
|
24
|
+
description = excluded.description,
|
|
25
|
+
author = excluded.author,
|
|
26
|
+
repository_name = excluded.repository_name,
|
|
27
|
+
creation_date = excluded.creation_date,
|
|
28
|
+
last_modified_date = excluded.last_modified_date,
|
|
29
|
+
status = excluded.status,
|
|
30
|
+
source_branch = excluded.source_branch,
|
|
31
|
+
destination_branch = excluded.destination_branch,
|
|
32
|
+
is_mergeable = excluded.is_mergeable,
|
|
33
|
+
is_approved = excluded.is_approved,
|
|
34
|
+
comment_count = COALESCE(excluded.comment_count, pull_requests.comment_count),
|
|
35
|
+
health_score = COALESCE(excluded.health_score, pull_requests.health_score),
|
|
36
|
+
link = excluded.link,
|
|
37
|
+
approved_by = COALESCE(excluded.approved_by, pull_requests.approved_by),
|
|
38
|
+
fetched_at = excluded.fetched_at`;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const deleteStale_ = SqlSchema.void({
|
|
42
|
+
Request: Schema.Struct({ olderThan: Schema.String }),
|
|
43
|
+
execute: (req) => sql `DELETE FROM pull_requests WHERE fetched_at < ${req.olderThan}`
|
|
44
|
+
});
|
|
45
|
+
const deleteStaleOpen_ = SqlSchema.void({
|
|
46
|
+
Request: Schema.Struct({ olderThan: Schema.String }),
|
|
47
|
+
execute: (req) => sql `DELETE FROM pull_requests WHERE status = 'OPEN' AND fetched_at < ${req.olderThan}`
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
upsert: (input) => upsert_(input).pipe(Effect.tap(() => publish), cacheError("upsert")),
|
|
51
|
+
upsertMany: (prs) => sql.withTransaction(Effect.forEach(prs, (pr) => upsert_(pr), { discard: true })).pipe(Effect.tap(() => publish), cacheError("upsertMany")),
|
|
52
|
+
deleteStale: (olderThan) => deleteStale_({ olderThan }).pipe(Effect.tap(() => publish), cacheError("deleteStale")),
|
|
53
|
+
deleteStaleOpen: (olderThan) => deleteStaleOpen_({ olderThan }).pipe(Effect.tap(() => publish), cacheError("deleteStaleOpen")),
|
|
54
|
+
deleteOne: (awsAccountId, id) => sql `DELETE FROM pull_requests WHERE aws_account_id = ${awsAccountId} AND id = ${id}`.pipe(Effect.asVoid, Effect.tap(() => publish), cacheError("deleteOne")),
|
|
55
|
+
updateDiffStats: (awsAccountId, id, filesAdded, filesModified, filesDeleted) => sql `UPDATE pull_requests SET files_added = ${filesAdded}, files_modified = ${filesModified}, files_deleted = ${filesDeleted}
|
|
56
|
+
WHERE id = ${id} AND aws_account_id = ${awsAccountId}`.pipe(Effect.asVoid, Effect.tap(() => publish), cacheError("updateDiffStats")),
|
|
57
|
+
updateStatusAndClosedAt: (awsAccountId, id, status, closedAt, mergedBy, approvedBy) => {
|
|
58
|
+
const approvedByStr = approvedBy ? joinApprovedBy([...approvedBy]) : null;
|
|
59
|
+
return sql `UPDATE pull_requests SET status = ${status}, closed_at = ${closedAt}, merged_by = ${mergedBy ?? null},
|
|
60
|
+
approved_by = COALESCE(${approvedByStr}, approved_by),
|
|
61
|
+
last_modified_date = ${closedAt}
|
|
62
|
+
WHERE id = ${id} AND aws_account_id = ${awsAccountId}`.pipe(Effect.asVoid, Effect.tap(() => publish), cacheError("updateStatusAndClosedAt"));
|
|
63
|
+
},
|
|
64
|
+
updateCommentCount: (awsAccountId, id, count) => sql `UPDATE pull_requests SET comment_count = ${count}
|
|
65
|
+
WHERE id = ${id} AND aws_account_id = ${awsAccountId}`.pipe(Effect.asVoid, Effect.tap(() => publish), cacheError("updateCommentCount")),
|
|
66
|
+
updateHealthScore: (awsAccountId, id, score) => sql `UPDATE pull_requests SET health_score = ${score}
|
|
67
|
+
WHERE id = ${id} AND aws_account_id = ${awsAccountId}`.pipe(Effect.asVoid, Effect.tap(() => publish), cacheError("updateHealthScore")),
|
|
68
|
+
refreshCommentedBy: () => sql.withTransaction(Effect.gen(function* () {
|
|
69
|
+
const LocationsFromJson = Schema.parseJson(Schema.Array(PRCommentLocationJson));
|
|
70
|
+
const rows = yield* sql `
|
|
71
|
+
SELECT c.aws_account_id, c.pull_request_id, p.author, c.locations_json
|
|
72
|
+
FROM pr_comments c
|
|
73
|
+
INNER JOIN pull_requests p ON p.id = c.pull_request_id AND p.aws_account_id = c.aws_account_id
|
|
74
|
+
`;
|
|
75
|
+
for (const row of rows) {
|
|
76
|
+
const parsed = yield* Schema.decodeUnknown(LocationsFromJson)(row.locationsJson).pipe(Effect.catchAll(() => Effect.succeed([])));
|
|
77
|
+
const commenters = new Set();
|
|
78
|
+
const walk = (threads) => {
|
|
79
|
+
for (const t of threads) {
|
|
80
|
+
if (t.root.author !== row.author)
|
|
81
|
+
commenters.add(t.root.author);
|
|
82
|
+
walk(t.replies);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
for (const loc of parsed)
|
|
86
|
+
walk(loc.comments);
|
|
87
|
+
const commentedBy = commenters.size > 0 ? [...commenters].join(",") : null;
|
|
88
|
+
yield* sql `UPDATE pull_requests SET commented_by = ${commentedBy}
|
|
89
|
+
WHERE id = ${row.pullRequestId} AND aws_account_id = ${row.awsAccountId}`;
|
|
90
|
+
}
|
|
91
|
+
})).pipe(Effect.asVoid, cacheError("refreshCommentedBy"))
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=mutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../../../src/CacheService/repos/PullRequestRepo/mutations.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM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C,GAAG,CAAC,QAAQ,CAAC,CAAA;gBAC5C,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;gBAC1E,KAAK,CAAC,CAAC,GAAG,CAAA,2CAA2C,WAAW;qCACvC,GAAG,CAAC,aAAa,yBAAyB,GAAG,CAAC,YAAY,EAAE,CAAA;YACvF,CAAC;QACH,CAAC,CAAC,CACH,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC;KACjD,CAAA;AACZ,CAAC,CAAA"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module PullRequestRepo/queries
|
|
3
|
+
*
|
|
4
|
+
* Read-only SQL queries. Each function takes `sql` (SqlClient) and returns
|
|
5
|
+
* the query implementation for the PullRequestRepo service.
|
|
6
|
+
*
|
|
7
|
+
* @category CacheService
|
|
8
|
+
*/
|
|
9
|
+
import type * as SqlClient from "@effect/sql/SqlClient";
|
|
10
|
+
import { Effect, Option } from "effect";
|
|
11
|
+
import type { CacheError } from "../../CacheError.js";
|
|
12
|
+
import { type SearchResult } from "./internal.js";
|
|
13
|
+
export declare const findAll: (sql: SqlClient.SqlClient) => () => Effect.Effect<readonly {
|
|
14
|
+
readonly link: string;
|
|
15
|
+
readonly awsAccountId: string;
|
|
16
|
+
readonly id: string & import("effect/Brand").Brand<"PullRequestId">;
|
|
17
|
+
readonly title: string;
|
|
18
|
+
readonly author: string;
|
|
19
|
+
readonly repositoryName: string & import("effect/Brand").Brand<"RepositoryName">;
|
|
20
|
+
readonly creationDate: Date;
|
|
21
|
+
readonly lastModifiedDate: Date;
|
|
22
|
+
readonly status: "OPEN" | "CLOSED" | "MERGED";
|
|
23
|
+
readonly sourceBranch: string;
|
|
24
|
+
readonly destinationBranch: string;
|
|
25
|
+
readonly isMergeable: boolean;
|
|
26
|
+
readonly isApproved: boolean;
|
|
27
|
+
readonly description: string | null;
|
|
28
|
+
readonly commentCount: number | null;
|
|
29
|
+
readonly healthScore: number | null;
|
|
30
|
+
readonly fetchedAt: string;
|
|
31
|
+
readonly approvedBy: readonly string[];
|
|
32
|
+
readonly commentedBy: readonly string[];
|
|
33
|
+
readonly mergedBy: string | null;
|
|
34
|
+
readonly accountProfile: string & import("effect/Brand").Brand<"AwsProfileName">;
|
|
35
|
+
readonly accountRegion: string & import("effect/Brand").Brand<"AwsRegion">;
|
|
36
|
+
readonly filesAdded: number | null;
|
|
37
|
+
readonly filesModified: number | null;
|
|
38
|
+
readonly filesDeleted: number | null;
|
|
39
|
+
readonly closedAt: string | null;
|
|
40
|
+
}[], CacheError, never>;
|
|
41
|
+
export declare const findMissingDiffStats: (sql: SqlClient.SqlClient) => () => Effect.Effect<readonly {
|
|
42
|
+
readonly link: string;
|
|
43
|
+
readonly awsAccountId: string;
|
|
44
|
+
readonly id: string & import("effect/Brand").Brand<"PullRequestId">;
|
|
45
|
+
readonly title: string;
|
|
46
|
+
readonly author: string;
|
|
47
|
+
readonly repositoryName: string & import("effect/Brand").Brand<"RepositoryName">;
|
|
48
|
+
readonly creationDate: Date;
|
|
49
|
+
readonly lastModifiedDate: Date;
|
|
50
|
+
readonly status: "OPEN" | "CLOSED" | "MERGED";
|
|
51
|
+
readonly sourceBranch: string;
|
|
52
|
+
readonly destinationBranch: string;
|
|
53
|
+
readonly isMergeable: boolean;
|
|
54
|
+
readonly isApproved: boolean;
|
|
55
|
+
readonly description: string | null;
|
|
56
|
+
readonly commentCount: number | null;
|
|
57
|
+
readonly healthScore: number | null;
|
|
58
|
+
readonly fetchedAt: string;
|
|
59
|
+
readonly approvedBy: readonly string[];
|
|
60
|
+
readonly commentedBy: readonly string[];
|
|
61
|
+
readonly mergedBy: string | null;
|
|
62
|
+
readonly accountProfile: string & import("effect/Brand").Brand<"AwsProfileName">;
|
|
63
|
+
readonly accountRegion: string & import("effect/Brand").Brand<"AwsRegion">;
|
|
64
|
+
readonly filesAdded: number | null;
|
|
65
|
+
readonly filesModified: number | null;
|
|
66
|
+
readonly filesDeleted: number | null;
|
|
67
|
+
readonly closedAt: string | null;
|
|
68
|
+
}[], CacheError, never>;
|
|
69
|
+
export declare const findByAccountAndId: (sql: SqlClient.SqlClient) => (awsAccountId: string, id: string) => Effect.Effect<Option.Option<{
|
|
70
|
+
readonly link: string;
|
|
71
|
+
readonly awsAccountId: string;
|
|
72
|
+
readonly id: string & import("effect/Brand").Brand<"PullRequestId">;
|
|
73
|
+
readonly title: string;
|
|
74
|
+
readonly author: string;
|
|
75
|
+
readonly repositoryName: string & import("effect/Brand").Brand<"RepositoryName">;
|
|
76
|
+
readonly creationDate: Date;
|
|
77
|
+
readonly lastModifiedDate: Date;
|
|
78
|
+
readonly status: "OPEN" | "CLOSED" | "MERGED";
|
|
79
|
+
readonly sourceBranch: string;
|
|
80
|
+
readonly destinationBranch: string;
|
|
81
|
+
readonly isMergeable: boolean;
|
|
82
|
+
readonly isApproved: boolean;
|
|
83
|
+
readonly description: string | null;
|
|
84
|
+
readonly commentCount: number | null;
|
|
85
|
+
readonly healthScore: number | null;
|
|
86
|
+
readonly fetchedAt: string;
|
|
87
|
+
readonly approvedBy: readonly string[];
|
|
88
|
+
readonly commentedBy: readonly string[];
|
|
89
|
+
readonly mergedBy: string | null;
|
|
90
|
+
readonly accountProfile: string & import("effect/Brand").Brand<"AwsProfileName">;
|
|
91
|
+
readonly accountRegion: string & import("effect/Brand").Brand<"AwsRegion">;
|
|
92
|
+
readonly filesAdded: number | null;
|
|
93
|
+
readonly filesModified: number | null;
|
|
94
|
+
readonly filesDeleted: number | null;
|
|
95
|
+
readonly closedAt: string | null;
|
|
96
|
+
}>, CacheError, never>;
|
|
97
|
+
export declare const search: (sql: SqlClient.SqlClient) => (query: string, opts?: {
|
|
98
|
+
readonly limit?: number;
|
|
99
|
+
readonly offset?: number;
|
|
100
|
+
}) => Effect.Effect<SearchResult, CacheError>;
|
|
101
|
+
export declare const findStaleOpen: (sql: SqlClient.SqlClient) => (olderThan: string) => Effect.Effect<readonly {
|
|
102
|
+
readonly awsAccountId: string;
|
|
103
|
+
readonly id: string;
|
|
104
|
+
readonly accountProfile: string & import("effect/Brand").Brand<"AwsProfileName">;
|
|
105
|
+
readonly accountRegion: string & import("effect/Brand").Brand<"AwsRegion">;
|
|
106
|
+
}[], CacheError, never>;
|
|
107
|
+
export declare const findOpenInRange: (sql: SqlClient.SqlClient) => (weekStart: string, weekEnd: string) => Effect.Effect<readonly {
|
|
108
|
+
readonly awsAccountId: string;
|
|
109
|
+
readonly id: string;
|
|
110
|
+
readonly accountProfile: string & import("effect/Brand").Brand<"AwsProfileName">;
|
|
111
|
+
readonly accountRegion: string & import("effect/Brand").Brand<"AwsRegion">;
|
|
112
|
+
}[], CacheError, never>;
|
|
113
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../../src/CacheService/repos/PullRequestRepo/queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,KAAK,SAAS,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAA;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,eAAe,CAAA;AAStB,eAAO,MAAM,OAAO,GAAI,KAAK,SAAS,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAO/C,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,KAAK,SAAS,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAO5D,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,KAAK,SAAS,CAAC,SAAS,MAQjD,cAAc,MAAM,EAAE,IAAI,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;sBACzC,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,KAAK,SAAS,CAAC,SAAS,MAsB3C,OAAO,MAAM,EACb,OAAO;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3D,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAoB1C,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,KAAK,SAAS,CAAC,SAAS,MAS5C,WAAW,MAAM;;;;;uBAC1B,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,KAAK,SAAS,CAAC,SAAS,MAa9C,WAAW,MAAM,EAAE,SAAS,MAAM;;;;;uBAC3C,CAAA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as SqlSchema from "@effect/sql/SqlSchema";
|
|
2
|
+
import { Effect, Option, Schema } from "effect";
|
|
3
|
+
import { AwsProfileName, AwsRegion } from "../../../Domain.js";
|
|
4
|
+
import { CachedPullRequest as CachedPullRequestSchema, cacheError } from "./internal.js";
|
|
5
|
+
const StaleOpenRow = Schema.Struct({
|
|
6
|
+
id: Schema.String,
|
|
7
|
+
awsAccountId: Schema.String,
|
|
8
|
+
accountProfile: AwsProfileName,
|
|
9
|
+
accountRegion: AwsRegion
|
|
10
|
+
});
|
|
11
|
+
export const findAll = (sql) => {
|
|
12
|
+
const run = SqlSchema.findAll({
|
|
13
|
+
Result: CachedPullRequestSchema,
|
|
14
|
+
Request: Schema.Void,
|
|
15
|
+
execute: () => sql `SELECT * FROM pull_requests ORDER BY creation_date DESC`
|
|
16
|
+
});
|
|
17
|
+
return () => run(undefined).pipe(cacheError("findAll"));
|
|
18
|
+
};
|
|
19
|
+
export const findMissingDiffStats = (sql) => {
|
|
20
|
+
const run = SqlSchema.findAll({
|
|
21
|
+
Result: CachedPullRequestSchema,
|
|
22
|
+
Request: Schema.Void,
|
|
23
|
+
execute: () => sql `SELECT * FROM pull_requests WHERE files_added IS NULL ORDER BY creation_date DESC`
|
|
24
|
+
});
|
|
25
|
+
return () => run(undefined).pipe(cacheError("findMissingDiffStats"));
|
|
26
|
+
};
|
|
27
|
+
export const findByAccountAndId = (sql) => {
|
|
28
|
+
const run = SqlSchema.findOne({
|
|
29
|
+
Result: CachedPullRequestSchema,
|
|
30
|
+
Request: Schema.Struct({ awsAccountId: Schema.String, id: Schema.String }),
|
|
31
|
+
execute: (req) => sql `SELECT * FROM pull_requests
|
|
32
|
+
WHERE aws_account_id = ${req.awsAccountId} AND id = ${req.id}`
|
|
33
|
+
});
|
|
34
|
+
return (awsAccountId, id) => run({ awsAccountId, id }).pipe(cacheError("findByAccountAndId"));
|
|
35
|
+
};
|
|
36
|
+
export const search = (sql) => {
|
|
37
|
+
const search_ = SqlSchema.findAll({
|
|
38
|
+
Result: CachedPullRequestSchema,
|
|
39
|
+
Request: Schema.Struct({ query: Schema.String, limit: Schema.Number, offset: Schema.Number }),
|
|
40
|
+
execute: (req) => sql `SELECT pull_requests.* FROM pull_requests
|
|
41
|
+
JOIN pull_requests_fts fts ON pull_requests.rowid = fts.rowid
|
|
42
|
+
WHERE pull_requests_fts MATCH ${req.query}
|
|
43
|
+
ORDER BY rank
|
|
44
|
+
LIMIT ${req.limit} OFFSET ${req.offset}`
|
|
45
|
+
});
|
|
46
|
+
const searchCount_ = SqlSchema.findOne({
|
|
47
|
+
Result: Schema.Struct({ count: Schema.Number }),
|
|
48
|
+
Request: Schema.Struct({ query: Schema.String }),
|
|
49
|
+
execute: (req) => sql `SELECT count(*) as count FROM pull_requests
|
|
50
|
+
JOIN pull_requests_fts fts ON pull_requests.rowid = fts.rowid
|
|
51
|
+
WHERE pull_requests_fts MATCH ${req.query}`
|
|
52
|
+
});
|
|
53
|
+
return (query, opts) => {
|
|
54
|
+
const limit = opts?.limit ?? 20;
|
|
55
|
+
const offset = opts?.offset ?? 0;
|
|
56
|
+
const stripped = query.replace(/[*^"]/g, "").replace(/\b(NEAR|OR|NOT|AND)\b/gi, "");
|
|
57
|
+
const escaped = stripped.replace(/"/g, `""`);
|
|
58
|
+
const ftsQuery = `"${escaped}"`;
|
|
59
|
+
return Effect.all({
|
|
60
|
+
items: search_({ query: ftsQuery, limit, offset }),
|
|
61
|
+
total: searchCount_({ query: ftsQuery }).pipe(Effect.map((r) => r.pipe(Option.getOrElse(() => ({ count: 0 }))).count))
|
|
62
|
+
}).pipe(Effect.map(({ items, total }) => ({ items, total, hasMore: offset + items.length < total })), Effect.catchTag("SqlError", () => Effect.logWarning("FTS search failed").pipe(Effect.as({ items: [], total: 0, hasMore: false }))), cacheError("search"));
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export const findStaleOpen = (sql) => {
|
|
66
|
+
const run = SqlSchema.findAll({
|
|
67
|
+
Result: StaleOpenRow,
|
|
68
|
+
Request: Schema.Struct({ olderThan: Schema.String }),
|
|
69
|
+
execute: (req) => sql `SELECT id, aws_account_id, account_profile, account_region
|
|
70
|
+
FROM pull_requests
|
|
71
|
+
WHERE status = 'OPEN' AND fetched_at < ${req.olderThan}`
|
|
72
|
+
});
|
|
73
|
+
return (olderThan) => run({ olderThan }).pipe(cacheError("findStaleOpen"));
|
|
74
|
+
};
|
|
75
|
+
export const findOpenInRange = (sql) => {
|
|
76
|
+
const run = SqlSchema.findAll({
|
|
77
|
+
Result: StaleOpenRow,
|
|
78
|
+
Request: Schema.Struct({ weekStart: Schema.String, weekEnd: Schema.String }),
|
|
79
|
+
execute: (req) => sql `SELECT id, aws_account_id, account_profile, account_region
|
|
80
|
+
FROM pull_requests
|
|
81
|
+
WHERE status = 'OPEN'
|
|
82
|
+
AND (
|
|
83
|
+
(creation_date >= ${req.weekStart} AND creation_date < ${req.weekEnd})
|
|
84
|
+
OR (last_modified_date >= ${req.weekStart} AND last_modified_date < ${req.weekEnd})
|
|
85
|
+
)`
|
|
86
|
+
});
|
|
87
|
+
return (weekStart, weekEnd) => run({ weekStart, weekEnd }).pipe(cacheError("findOpenInRange"));
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../../src/CacheService/repos/PullRequestRepo/queries.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9D,OAAO,EAEL,iBAAiB,IAAI,uBAAuB,EAC5C,UAAU,EAEX,MAAM,eAAe,CAAA;AAEtB,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACjC,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,YAAY,EAAE,MAAM,CAAC,MAAM;IAC3B,cAAc,EAAE,cAAc;IAC9B,aAAa,EAAE,SAAS;CACzB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAwB,EAAE,EAAE;IAClD,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC;QAC5B,MAAM,EAAE,uBAAuB;QAC/B,OAAO,EAAE,MAAM,CAAC,IAAI;QACpB,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAA,yDAAyD;KAC5E,CAAC,CAAA;IACF,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,SAAiB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAA;AACjE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAwB,EAAE,EAAE;IAC/D,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC;QAC5B,MAAM,EAAE,uBAAuB;QAC/B,OAAO,EAAE,MAAM,CAAC,IAAI;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AAE,CAAC;QAC5E,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CACf,GAAG,CAAA;;;;kCAIyB,GAAG,CAAC,SAAS,wBAAwB,GAAG,CAAC,OAAO;0CACxC,GAAG,CAAC,SAAS,6BAA6B,GAAG,CAAC,OAAO;cACjF;KACX,CAAC,CAAA;IACF,OAAO,CAAC,SAAiB,EAAE,OAAe,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAChH,CAAC,CAAA"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module StatsRepo
|
|
3
|
+
*
|
|
4
|
+
* Read-only SQL projection layer for the statistics dashboard.
|
|
5
|
+
* Assembles query methods from `./queries` and `./reviewerData` into
|
|
6
|
+
* a single Effect.Service.
|
|
7
|
+
*
|
|
8
|
+
* @category CacheService
|
|
9
|
+
*/
|
|
10
|
+
import * as SqlClient from "@effect/sql/SqlClient";
|
|
11
|
+
import { Effect } from "effect";
|
|
12
|
+
declare const StatsRepo_base: Effect.Service.Class<StatsRepo, "StatsRepo", {
|
|
13
|
+
readonly dependencies: readonly [import("effect/Layer").Layer<SqlClient.SqlClient | import("@effect/sql-libsql/LibsqlClient").LibsqlClient, import("@effect/sql/SqlError").SqlError | import("effect/ConfigError").ConfigError | import("@effect/sql/Migrator").MigrationError, import("@effect/platform/FileSystem").FileSystem>];
|
|
14
|
+
readonly effect: Effect.Effect<{
|
|
15
|
+
readonly weeklyVolume: (weekStart: string, weekEnd: string, filters: import("./internal.ts").Filters) => Effect.Effect<import("./internal.ts").VolumeRow, import("../../CacheError.ts").CacheError, never>;
|
|
16
|
+
readonly topContributors: (weekStart: string, weekEnd: string, filters: import("./internal.ts").Filters, limit?: number) => Effect.Effect<readonly import("./internal.ts").ContributorRow[], import("../../CacheError.ts").CacheError, never>;
|
|
17
|
+
readonly mostActivePRs: (weekStart: string, weekEnd: string, filters: import("./internal.ts").Filters, limit?: number) => Effect.Effect<readonly import("./internal.ts").ActivePRRow[], import("../../CacheError.ts").CacheError, never>;
|
|
18
|
+
readonly prSizeDistribution: (weekStart: string, weekEnd: string, filters: import("./internal.ts").Filters) => Effect.Effect<import("./internal.ts").SizeDistributionRow, import("../../CacheError.ts").CacheError, never>;
|
|
19
|
+
readonly avgDiffSize: (weekStart: string, weekEnd: string, filters: import("./internal.ts").Filters) => Effect.Effect<{
|
|
20
|
+
filesAdded: number;
|
|
21
|
+
filesModified: number;
|
|
22
|
+
filesDeleted: number;
|
|
23
|
+
} | null, import("../../CacheError.ts").CacheError, never>;
|
|
24
|
+
readonly diffSizeByContributor: (weekStart: string, weekEnd: string, filters: import("./internal.ts").Filters, limit?: number) => Effect.Effect<readonly import("./internal.ts").DiffByContributorRow[], import("../../CacheError.ts").CacheError, never>;
|
|
25
|
+
readonly stalePRs: (nowISO: string, filters: import("./internal.ts").Filters, limit?: number) => Effect.Effect<readonly import("./internal.ts").StalePRRow[], import("../../CacheError.ts").CacheError, never>;
|
|
26
|
+
readonly healthIndicators: (weekStart: string, weekEnd: string, filters: import("./internal.ts").Filters) => Effect.Effect<import("./internal.ts").HealthRow, import("../../CacheError.ts").CacheError, never>;
|
|
27
|
+
readonly filterOptions: () => Effect.Effect<{
|
|
28
|
+
repos: string[];
|
|
29
|
+
authors: string[];
|
|
30
|
+
accounts: string[];
|
|
31
|
+
}, import("../../CacheError.ts").CacheError, never>;
|
|
32
|
+
readonly totalComments: (weekStart: string, weekEnd: string, filters: import("./internal.ts").Filters) => Effect.Effect<number, import("../../CacheError.ts").CacheError, never>;
|
|
33
|
+
readonly reviewerData: (weekStart: string, weekEnd: string, filters: import("./internal.ts").Filters) => Effect.Effect<{
|
|
34
|
+
topReviewers: {
|
|
35
|
+
author: string;
|
|
36
|
+
commentCount: number;
|
|
37
|
+
}[];
|
|
38
|
+
topApprovers: {
|
|
39
|
+
author: string;
|
|
40
|
+
approvalCount: number;
|
|
41
|
+
}[];
|
|
42
|
+
avgTimeToFirstReview: number | null;
|
|
43
|
+
avgTimeToMerge: number | null;
|
|
44
|
+
avgTimeToAddressFeedback: number | null;
|
|
45
|
+
firstReviewDetails: {
|
|
46
|
+
prId: string;
|
|
47
|
+
prTitle: string;
|
|
48
|
+
author: string;
|
|
49
|
+
repositoryName: string;
|
|
50
|
+
awsAccountId: string;
|
|
51
|
+
durationMs: number;
|
|
52
|
+
fromLabel: string;
|
|
53
|
+
toLabel: string;
|
|
54
|
+
}[];
|
|
55
|
+
feedbackDetails: {
|
|
56
|
+
prId: string;
|
|
57
|
+
prTitle: string;
|
|
58
|
+
author: string;
|
|
59
|
+
repositoryName: string;
|
|
60
|
+
awsAccountId: string;
|
|
61
|
+
durationMs: number;
|
|
62
|
+
fromLabel: string;
|
|
63
|
+
toLabel: string;
|
|
64
|
+
}[];
|
|
65
|
+
}, import("../../CacheError.ts").CacheError, never>;
|
|
66
|
+
readonly mergeTimeDetails: (weekStart: string, weekEnd: string, filters: import("./internal.ts").Filters) => Effect.Effect<{
|
|
67
|
+
prId: string;
|
|
68
|
+
prTitle: string;
|
|
69
|
+
author: string;
|
|
70
|
+
repositoryName: string;
|
|
71
|
+
awsAccountId: string;
|
|
72
|
+
durationMs: number;
|
|
73
|
+
fromLabel: string;
|
|
74
|
+
toLabel: string;
|
|
75
|
+
}[], import("../../CacheError.ts").CacheError, never>;
|
|
76
|
+
readonly avgTimeToMerge: (weekStart: string, weekEnd: string, filters: import("./internal.ts").Filters) => Effect.Effect<number | null, import("../../CacheError.ts").CacheError, never>;
|
|
77
|
+
readonly dataAvailableSince: () => Effect.Effect<string | null, import("../../CacheError.ts").CacheError, never>;
|
|
78
|
+
}, never, SqlClient.SqlClient>;
|
|
79
|
+
}>;
|
|
80
|
+
export declare class StatsRepo extends StatsRepo_base {
|
|
81
|
+
}
|
|
82
|
+
export declare namespace StatsRepo {
|
|
83
|
+
/**
|
|
84
|
+
* @category models
|
|
85
|
+
*/
|
|
86
|
+
interface Filters {
|
|
87
|
+
readonly repo?: string | undefined;
|
|
88
|
+
readonly author?: string | undefined;
|
|
89
|
+
readonly account?: string | undefined;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/CacheService/repos/StatsRepo/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAS/B,qBAAa,SAAU,SAAQ,cAsB7B;CAAG;AAEL,MAAM,CAAC,OAAO,WAAW,SAAS,CAAC;IACjC;;OAEG;IACH,UAAiB,OAAO;QACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KACtC;CACF"}
|