diff --git a/src/looker_api_types.ts b/src/looker_api_types.ts index 020d8cb7..14174766 100644 --- a/src/looker_api_types.ts +++ b/src/looker_api_types.ts @@ -57,6 +57,7 @@ export interface IQuery { type?: string; hidden_fields?: string[]; show_view_names: boolean; + series_labels: { [key: string]: string }; [key: string]: any; } client_id?: string | null // deprecated diff --git a/src/repliers/slack_table_formatter.ts b/src/repliers/slack_table_formatter.ts index bb299112..4acdbf7e 100644 --- a/src/repliers/slack_table_formatter.ts +++ b/src/repliers/slack_table_formatter.ts @@ -11,6 +11,7 @@ export class SlackTableFormatter { private fields: any[] private query: IQuery private result: IQueryResponse + private customLabels: { [key: string]: string } constructor( private options: {query: IQuery, result: IQueryResponse, baseUrl: string, shareUrl: string}, @@ -28,6 +29,9 @@ export class SlackTableFormatter { } } + // get custom labels + this.customLabels = this.query.vis_config.series_labels + const calcs = this.result.fields.table_calculations || [] const dimensions = this.result.fields.dimensions || [] const measures = this.result.fields.measures || [] @@ -110,6 +114,11 @@ export class SlackTableFormatter { } private renderFieldLabel(field: IQueryResponseField): string { + + if (this.customLabels[field.name]) { + return this.customLabels[field.name] + } + let showViewNames: boolean if (!this.query.vis_config || typeof this.query.vis_config.show_view_names === "undefined") { showViewNames = true