Skip to content

Instantly share code, notes, and snippets.

@uditalias
Last active February 23, 2019 20:44
Show Gist options
  • Save uditalias/f3075e877a6be74524e68d167944e7e6 to your computer and use it in GitHub Desktop.
Save uditalias/f3075e877a6be74524e68d167944e7e6 to your computer and use it in GitHub Desktop.
@cache({ maxAge: TEN_MINUTES_IN_MILLISECONDS, multi: true })
public async generate(owner: string, repo: string, options: ILangaugeOptions): Promise<Buffer> {
try {
const createRenderer = this.rendererCreators[options.type];
let languages = await this.githubService.getRepositoryLanguages(owner, repo);
if (options.threshold) {
languages = this.thresholdLanguagesFilter(languages, options.threshold);
}
const totalBytes = _(languages).values().sum();
const renderer = createRenderer(options, totalBytes, languages);
return await renderer.render();
} catch (err) {
this.logger.error(`failed to render langauge for type ${options.type}`, err);
return Buffer.from("");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment