Skip to content

Commit

Permalink
fix(server): resource timings where off due to async functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ADRFranklin committed Jun 10, 2024
1 parent 8e8fc8d commit eaa6ad7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions server/src/services/movie/movie-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class MovieService {
options && Object.keys(options).length ? toQueryString(options) : '';
const cacheName = `movie.${id}${optionsAsString}`;
try {
const start = Date.now();
const start = performance.now();
const result = await this.cacheProvider.wrap(
cacheName,
async () => {
Expand Down Expand Up @@ -109,10 +109,10 @@ export class MovieService {
);
return None;
}
const end = Date.now();
const end = performance.now();
this.logger.debug(
{ movieId: id, name: result.title },
`got movie details in ${end - start}ms`,
`got movie details in ${Math.round(end - start)}ms`,
);
return Some(MovieEntity.create(result));
} catch (error) {
Expand Down
6 changes: 3 additions & 3 deletions server/src/services/person/person-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class PersonService {
options?: GetDetailsOptions,
): Promise<Option<PersonEntity>> {
try {
const start = Date.now();
const start = performance.now();
const personResult = await this.personDetailsProvider.getDetails(id);
if (!personResult.isOk()) {
return None;
Expand All @@ -68,10 +68,10 @@ export class PersonService {
),
]);
}
const end = Date.now();
const end = performance.now();
this.logger.debug(
{ personId: id, name: person.name },
`got person details in ${end - start}ms`,
`got person details in ${Math.round(end - start)}ms`,
);
return Some(person);
} catch (error) {
Expand Down
6 changes: 3 additions & 3 deletions server/src/services/show/show-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class ShowService {
options && Object.keys(options).length ? toQueryString(options) : '';
const cacheName = `show.${id}${optionsAsString}`;
try {
const start = Date.now();
const start = performance.now();
const result = await this.cacheProvider.wrap<ShowProps | undefined>(
cacheName,
async () => {
Expand Down Expand Up @@ -109,10 +109,10 @@ export class ShowService {
this.logger.debug({ showId: id }, 'show not found');
return None;
}
const end = Date.now();
const end = performance.now();
this.logger.debug(
{ showId: id, name: result.title, seasons: result.seasons.length },
`got show details in ${end - start}ms`,
`got show details in ${Math.round(end - start)}ms`,
);
return Some(ShowEntity.create(result));
} catch (error) {
Expand Down

0 comments on commit eaa6ad7

Please sign in to comment.