Skip to content

Commit 04aa3a4

Browse files
committed
get last modified date from changelog
1 parent 145637d commit 04aa3a4

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/components/apis/api-details-page/ko/runtime/api-details-page.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,9 @@ export class ApiDetailsPage {
137137
this.api(api);
138138
this.initializeBreadcrumbItems();
139139

140-
try {
141-
const currentApiVersion = await this.apiService.getCurrentRevision(apiName);
142-
this.lastModifiedDate(new Date(currentApiVersion.updatedDateTime).toLocaleDateString());
143-
}
144-
catch (error) {
145-
// do nothing
140+
const lastModifiedDate = await this.apiService.getLastModifiedDate(`apis/${apiName}`);
141+
if (lastModifiedDate) {
142+
this.lastModifiedDate(new Date(lastModifiedDate).toLocaleDateString());
146143
}
147144

148145
this.apiLoading(false);

src/services/apiService.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -579,13 +579,14 @@ export class ApiService {
579579
return new Wiki(wikiContract);
580580
}
581581

582-
public async getCurrentRevision(apiId: string): Promise<Revision> {
583-
let query = `apis/${apiId}/revisions`;
584-
query = Utils.addQueryParameter(query, `isCurrent eq true`);
585-
586-
const revisionContract = await this.mapiClient.get<Page<RevisionContract>>(query, [await this.mapiClient.getPortalHeader("getCurrentRevision")]);
587-
return new Revision(revisionContract.value[0]);
588-
}
582+
public async getLastModifiedDate(apiId: string): Promise<string> {
583+
let query = `${apiId}/releases`;
584+
query = Utils.addQueryParameter(query, `$orderBy=createdDateTime`);
585+
query = Utils.addQueryParameter(query, `$top=1`);
586+
587+
const changelog = await this.mapiClient.get<Page<ChangeLogContract>>(query, [await this.mapiClient.getPortalHeader("getApiChangeLog")]);
588+
return changelog?.value[0]?.properties.createdDateTime;
589+
}
589590

590591
private mapApiTagResourceToOperationsByTags(apiTagResource: PageContract<ApiTagResourceContract>): Page<TagGroup<Operation>> {
591592
const page = new Page<TagGroup<Operation>>();

0 commit comments

Comments
 (0)