Skip to content

Commit a66fe77

Browse files
Refactor to use auditKey and improve code consistency
Transitioned the system from using `runId` (integer) to `auditKey` (GUID) as the primary identifier for audits. Updated DTOs, APIs, database schemas, repositories, services, and UI components to reflect this change. Added a migration to ensure backward compatibility by retaining `runId` columns temporarily. Refactored variable names, class names, and aliases across the codebase to improve consistency and readability. Updated method calls, imports, and exports to align with the new naming conventions. Enhanced the maintainability and clarity of the codebase. Regenerated `index.js.map` to reflect changes in the corresponding `index.js` file, ensuring accurate source mapping for debugging.
1 parent 45da55b commit a66fe77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1338
-952
lines changed

src/Umbraco.Community.ContentAudit.UI/src/api/sdk.gen.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ export class AuditService {
2626
});
2727
}
2828

29+
public static getByKey<ThrowOnError extends boolean = true>(options: Options<GetByKeyData, ThrowOnError>) {
30+
return (options.client ?? client).get<GetByKeyResponses, unknown, ThrowOnError>({
31+
url: '/umbraco/content-audit/management/api/v1/audit/{id}',
32+
...options
33+
});
34+
}
35+
2936
public static getAllImages<ThrowOnError extends boolean = true>(options?: Options<GetAllImagesData, ThrowOnError>) {
3037
return (options?.client ?? client).get<GetAllImagesResponses, unknown, ThrowOnError>({
3138
url: '/umbraco/content-audit/management/api/v1/audit/all-images',
@@ -82,13 +89,6 @@ export class AuditService {
8289
});
8390
}
8491

85-
public static getByKey<ThrowOnError extends boolean = true>(options?: Options<GetByKeyData, ThrowOnError>) {
86-
return (options?.client ?? client).get<GetByKeyResponses, unknown, ThrowOnError>({
87-
url: '/umbraco/content-audit/management/api/v1/audit/latest-page-data',
88-
...options
89-
});
90-
}
91-
9292
public static getPagesWithMissingMetadata<ThrowOnError extends boolean = true>(options?: Options<GetPagesWithMissingMetadataData, ThrowOnError>) {
9393
return (options?.client ?? client).get<GetPagesWithMissingMetadataResponses, unknown, ThrowOnError>({
9494
url: '/umbraco/content-audit/management/api/v1/audit/missing-metadata',

src/Umbraco.Community.ContentAudit.UI/src/api/types.gen.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type ClientOptions = {
66

77
export type AccessibilityDto = {
88
id: number;
9-
runId: number;
9+
auditKey: string;
1010
url?: string | null;
1111
accessibilityIssues?: Array<string> | null;
1212
ariaLabelCount: number;
@@ -35,7 +35,7 @@ export type AuditTreeItemResponseModel = {
3535

3636
export type ContentAnalysisDto = {
3737
id: number;
38-
runId: number;
38+
auditKey: string;
3939
url?: string | null;
4040
wordCount: number;
4141
paragraphCount: number;
@@ -63,7 +63,7 @@ export type ContentAuditSettings = {
6363

6464
export type ContentQualityDto = {
6565
id: number;
66-
runId: number;
66+
auditKey: string;
6767
url?: string | null;
6868
hasDuplicateContent: boolean;
6969
duplicateContentUrls?: Array<string> | null;
@@ -101,7 +101,7 @@ export type HealthScoreDto = {
101101
export type ImageDto = {
102102
entityType: string;
103103
id: number;
104-
runId: number;
104+
auditKey: string;
105105
url?: string | null;
106106
isExternal: boolean;
107107
size?: number | null;
@@ -147,7 +147,7 @@ export type LinkDto = {
147147
unique: string;
148148
entityType: string;
149149
id: number;
150-
runId: number;
150+
auditKey: string;
151151
url?: string | null;
152152
isExternal: boolean;
153153
foundPage?: string | null;
@@ -222,7 +222,7 @@ export type PageAnalysisDto = {
222222
export type PageDto = {
223223
entityType: string;
224224
id: number;
225-
runId: number;
225+
auditKey: string;
226226
url?: string | null;
227227
redirect: boolean;
228228
redirectUrl?: string | null;
@@ -267,7 +267,7 @@ export type PagedPageDtoModel = {
267267

268268
export type PerformanceDto = {
269269
id: number;
270-
runId: number;
270+
auditKey: string;
271271
url?: string | null;
272272
pageLoadTime?: number | null;
273273
cumulativeLayoutShift?: MetricDto | null;
@@ -288,7 +288,7 @@ export type ReferenceByIdModel = {
288288
export type ResourceDto = {
289289
entityType: string;
290290
id: number;
291-
runId: number;
291+
auditKey: string;
292292
url?: string | null;
293293
isExternal: boolean;
294294
size?: number | null;
@@ -308,7 +308,7 @@ export type ResourceTimingDto = {
308308
};
309309

310310
export type SeoDto = {
311-
runId: number;
311+
auditKey: string;
312312
url?: string | null;
313313
title?: string | null;
314314
metaDescription?: string | null;
@@ -331,7 +331,7 @@ export type SeoDto = {
331331

332332
export type SocialMediaDto = {
333333
id: number;
334-
runId: number;
334+
auditKey: string;
335335
url?: string | null;
336336
socialShareButtons?: Array<string> | null;
337337
hasFacebookPixel: boolean;
@@ -343,7 +343,7 @@ export type SocialMediaDto = {
343343

344344
export type TechnicalSeoDto = {
345345
id: number;
346-
runId: number;
346+
auditKey: string;
347347
url?: string | null;
348348
contentType?: string | null;
349349
charset?: string | null;
@@ -400,6 +400,24 @@ export type GetCollectionResponses = {
400400

401401
export type GetCollectionResponse = GetCollectionResponses[keyof GetCollectionResponses];
402402

403+
export type GetByKeyData = {
404+
body?: never;
405+
path: {
406+
id: string;
407+
};
408+
query?: never;
409+
url: '/umbraco/content-audit/management/api/v1/audit/{id}';
410+
};
411+
412+
export type GetByKeyResponses = {
413+
/**
414+
* OK
415+
*/
416+
200: PageAnalysisDto;
417+
};
418+
419+
export type GetByKeyResponse = GetByKeyResponses[keyof GetByKeyResponses];
420+
403421
export type GetAllImagesData = {
404422
body?: never;
405423
path?: never;
@@ -549,24 +567,6 @@ export type GetLatestAuditDataResponses = {
549567

550568
export type GetLatestAuditDataResponse = GetLatestAuditDataResponses[keyof GetLatestAuditDataResponses];
551569

552-
export type GetByKeyData = {
553-
body?: never;
554-
path?: never;
555-
query?: {
556-
unique?: string;
557-
};
558-
url: '/umbraco/content-audit/management/api/v1/audit/latest-page-data';
559-
};
560-
561-
export type GetByKeyResponses = {
562-
/**
563-
* OK
564-
*/
565-
200: PageAnalysisDto;
566-
};
567-
568-
export type GetByKeyResponse = GetByKeyResponses[keyof GetByKeyResponses];
569-
570570
export type GetPagesWithMissingMetadataData = {
571571
body?: never;
572572
path?: never;

src/Umbraco.Community.ContentAudit.UI/src/documents/views/contentaudit-workspace-view.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class ContentAuditWorkspaceElement extends UmbElementMixin(LitElement) {
5454
this._data = data;
5555

5656
if (this._data != null) {
57-
if (this._data.pageData?.runId != 0) {
57+
if (this._data.pageData?.auditKey) {
5858
this._createRoutes();
5959
}
6060
}

src/Umbraco.Community.ContentAudit.UI/src/section/all-pages/repository/detail/all-pages-detail.server.data-source.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class ContentAuditAllPagesServerDataSource implements UmbReadDetailDataSo
1515

1616
const { data, error } = await tryExecute(
1717
this.#host,
18-
AuditService.getByKey({ query: { unique: unique } })
18+
AuditService.getByKey({ path: { id: unique } })
1919
);
2020

2121
if (error || !data) {

src/Umbraco.Community.ContentAudit.UI/src/section/audits/workspace/audits/manifests.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ export const manifests: Array<UmbExtensionManifest> = [
3030
},
3131
],
3232
},
33-
{
34-
type: 'workspaceView',
35-
alias: 'Umb.WorkspaceView.ContentAudit.Audits.Details',
36-
name: 'Audits Workspace Details View',
37-
js: () => import('./views/audits-details-workspace-view.element'),
38-
weight: 90,
39-
meta: {
40-
label: 'Details',
41-
pathname: 'details',
42-
icon: 'icon-info',
43-
},
44-
conditions: [
45-
{
46-
alias: UMB_WORKSPACE_CONDITION_ALIAS,
47-
match: CONTENT_AUDIT_AUDITS_WORKSPACE_ALIAS,
48-
},
49-
],
50-
},
33+
//{
34+
// type: 'workspaceView',
35+
// alias: 'Umb.WorkspaceView.ContentAudit.Audits.Details',
36+
// name: 'Audits Workspace Details View',
37+
// js: () => import('./views/audits-details-workspace-view.element'),
38+
// weight: 90,
39+
// meta: {
40+
// label: 'Details',
41+
// pathname: 'details',
42+
// icon: 'icon-info',
43+
// },
44+
// conditions: [
45+
// {
46+
// alias: UMB_WORKSPACE_CONDITION_ALIAS,
47+
// match: CONTENT_AUDIT_AUDITS_WORKSPACE_ALIAS,
48+
// },
49+
// ],
50+
//},
5151
{
5252
type: 'workspaceView',
5353
alias: 'Umb.WorkspaceView.ContentAudit.Audits.Issues',

src/Umbraco.Community.ContentAudit.UI/src/section/audits/workspace/audits/views/audits-overview-workspace-view.element.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ export class ContentAuditAuditsOverviewWorkspaceViewElement extends UmbLitElemen
5757
<strong>Run Date:</strong>
5858
<span>${this.localize.date(this._data.runDate, { dateStyle: 'long', timeStyle: 'short' })}</span>
5959
</div>
60-
<div class="info-item">
61-
<strong>Audit ID:</strong>
62-
<span>${this._data.id}</span>
63-
</div>
6460
<div class="info-item">
6561
<strong>Audit Key:</strong>
6662
<span>${this._data.key}</span>

src/Umbraco.Community.ContentAudit/Api/Audit/GetByKeyAuditController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ public GetByKeyAuditController(IDataService dataService) : base(dataService) { }
1818
/// <summary>
1919
/// Returns page analysis for the given unique identifier.
2020
/// </summary>
21-
/// <param name="unique">Page unique identifier.</param>
22-
[HttpGet("latest-page-data")]
21+
/// <param name="id">Page unique identifier.</param>
22+
[HttpGet("{id:guid}")]
2323
[ProducesResponseType(typeof(PageAnalysisDto), 200)]
24-
public async Task<PageAnalysisDto> GetByKey(Guid unique)
24+
public async Task<PageAnalysisDto> GetByKey(Guid id)
2525
{
26-
var latestData = await DataService.GetLatestPageAuditData(unique);
26+
var latestData = await DataService.GetAuditPageAnalysisByKey(id);
2727
return latestData;
2828
}
2929
}

src/Umbraco.Community.ContentAudit/Interfaces/IAuditRepository.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ namespace Umbraco.Community.ContentAudit.Interfaces
44
{
55
public interface IAuditRepository
66
{
7-
Task<int?> GetLatestAuditId();
8-
Task<IEnumerable<OverviewSchema>> GetLatestAuditOverview(int latestRunId);
9-
Task<IEnumerable<PageSchema>> GetPagesByRunId(int runId);
10-
Task<IEnumerable<SeoSchema>> GetSeoData(int runId, string url);
11-
Task<IEnumerable<ContentAnalysisSchema>> GetContentAnalysisData(int runId, string url);
12-
Task<IEnumerable<PerformanceSchema>> GetPerformanceData(int runId, string url);
13-
Task<IEnumerable<AccessibilitySchema>> GetAccessibilityData(int runId, string url);
14-
Task<IEnumerable<TechnicalSeoSchema>> GetTechnicalSeoData(int runId, string url);
15-
Task<IEnumerable<SocialMediaSchema>> GetSocialMediaData(int runId, string url);
16-
Task<IEnumerable<ContentQualitySchema>> GetContentQualityData(int runId, string url);
17-
Task<IEnumerable<LinkSchema>> GetLinkData(int runId, string foundPage);
18-
Task<IEnumerable<ResourceSchema>> GetResourceData(int runId, string foundPage);
19-
Task<IEnumerable<ImageSchema>> GetImageData(int runId, string foundPage);
7+
Task<Guid?> GetLatestAuditKey();
8+
Task<IEnumerable<OverviewSchema>> GetLatestAuditOverview(Guid auditKey);
9+
Task<IEnumerable<PageSchema>> GetPagesByAuditKey(Guid auditKey);
10+
Task<IEnumerable<SeoSchema>> GetSeoData(Guid auditKey, string url);
11+
Task<IEnumerable<ContentAnalysisSchema>> GetContentAnalysisData(Guid auditKey, string url);
12+
Task<IEnumerable<PerformanceSchema>> GetPerformanceData(Guid auditKey, string url);
13+
Task<IEnumerable<AccessibilitySchema>> GetAccessibilityData(Guid auditKey, string url);
14+
Task<IEnumerable<TechnicalSeoSchema>> GetTechnicalSeoData(Guid auditKey, string url);
15+
Task<IEnumerable<SocialMediaSchema>> GetSocialMediaData(Guid auditKey, string url);
16+
Task<IEnumerable<ContentQualitySchema>> GetContentQualityData(Guid auditKey, string url);
17+
Task<IEnumerable<LinkSchema>> GetLinkData(Guid auditKey, string foundPage);
18+
Task<IEnumerable<ResourceSchema>> GetResourceData(Guid auditKey, string foundPage);
19+
Task<IEnumerable<ImageSchema>> GetImageData(Guid auditKey, string foundPage);
2020
Task<IEnumerable<OverviewSchema>> GetAllAuditOverviews();
2121
}
2222
}

src/Umbraco.Community.ContentAudit/Interfaces/IDataService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace Umbraco.Community.ContentAudit.Interfaces
66
public interface IDataService
77
{
88
Task<OverviewDto> GetLatestAuditOverview();
9+
Task<PageAnalysisDto> GetAuditPageAnalysisByKey(Guid auditKey);
910
Task<List<PageAnalysisDto>> GetLatestAuditData(string filter = "", int statusCode = 0);
1011
Task<PageAnalysisDto> GetLatestPageAuditData(Guid unique);
1112
Task<List<PageDto>> GetOrphanedPages(string filter = "");

0 commit comments

Comments
 (0)