-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #719 from cbrianbet/feat/new-reporting-layer
monthly highlights api
- Loading branch information
Showing
7 changed files
with
60 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/self-service/metabase/queries/handlers/metabase-monthly-highlight.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { IQueryHandler, QueryHandler } from '@nestjs/cqrs'; | ||
import { GetMetabaseMonthlyHighlightQuery } from '../impl/metabase-monthly-highlight.query'; | ||
import { sign } from 'jsonwebtoken'; | ||
|
||
@QueryHandler(GetMetabaseMonthlyHighlightQuery) | ||
export class GetMetabaseMonthlyHighlightHandler implements IQueryHandler<GetMetabaseMonthlyHighlightQuery>{ | ||
|
||
async execute(query: GetMetabaseMonthlyHighlightQuery): Promise<any> { | ||
const METABASE_SITE_URL = "https://metabase.kenyahmis.org"; | ||
const METABASE_SECRET_KEY = '919930fd2520f0ea5d890526bdb68daaaa37b8412dba0108a86dba5add85be44'; | ||
|
||
let payload = { | ||
resource: { dashboard: 56 }, | ||
params: {} | ||
}; | ||
let token = sign(payload, METABASE_SECRET_KEY); | ||
|
||
return {url: METABASE_SITE_URL + "/embed/dashboard/" + token + "#bordered=true&titled=true"}; | ||
} | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
src/self-service/metabase/queries/impl/metabase-monthly-highlight.query.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class GetMetabaseMonthlyHighlightQuery { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Controller, Get, Query } from '@nestjs/common'; | ||
import { QueryBus } from '@nestjs/cqrs'; | ||
import { GetMetabaseMonthlyHighlightQuery } from './metabase/queries/impl/metabase-monthly-highlight.query'; | ||
|
||
|
||
@Controller('self-service') | ||
export class SelfServiceController { | ||
constructor(private readonly queryBus: QueryBus) {} | ||
|
||
@Get('monthly-highlight') | ||
async getHtsSites(): Promise<any> { | ||
return this.queryBus.execute(new GetMetabaseMonthlyHighlightQuery()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { CqrsModule } from '@nestjs/cqrs'; | ||
import { ConfigurationModule } from '../config/config.module'; | ||
import { SelfServiceController } from './self-service.controller'; | ||
import { GetMetabaseMonthlyHighlightHandler } from './metabase/queries/handlers/metabase-monthly-highlight.handler'; | ||
|
||
@Module({ | ||
imports: [ | ||
CqrsModule, | ||
ConfigurationModule, | ||
], | ||
providers: [ | ||
GetMetabaseMonthlyHighlightHandler | ||
|
||
], | ||
controllers: [SelfServiceController], | ||
}) | ||
export class SelfServiceModule {} |