Skip to content

Commit 9e41228

Browse files
author
Vikas Agarwal
committed
Handling looker embed reports in non production environment via mock look in the same instance.
1 parent 0af475e commit 9e41228

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

config/custom-environment-variables.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"CLIENT_SECRET": "LOOKER_API_CLIENT_SECRET",
6565
"TOKEN": "TOKEN",
6666
"USE_MOCK": "LOOKER_API_ENABLE_MOCK",
67+
"MOCK_EMBED_REPORT": "MOCK_EMBED_REPORT",
6768
"QUERIES": {
6869
"REG_STATS": "LOOKER_API_REG_STATS_QUERY_ID",
6970
"BUDGET": "LOOKER_API_BUDGET_QUERY_ID"

config/default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"CLIENT_SECRET": "",
7070
"TOKEN": "TOKEN",
7171
"USE_MOCK": "true",
72+
"MOCK_EMBED_REPORT": "/embed/looks/2",
7273
"QUERIES": {
7374
"REG_STATS": 1234,
7475
"BUDGET": 123

src/routes/projectReports/getEmbedReport.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-unused-vars */
2-
// import config from 'config';
2+
import config from 'config';
33
import _ from 'lodash';
44
import { middleware as tcMiddleware } from 'tc-core-library-js';
55
import util from '../../util';
@@ -13,7 +13,7 @@ module.exports = [
1313
permissions('projectReporting.managers'),
1414
async (req, res, next) => {
1515
const projectId = Number(req.params.projectId);
16-
const reportName = req.query.reportName;
16+
const reportName = config.lookerConfig.USE_MOCK ? 'mock' : req.query.reportName;
1717
const authUser = req.authUser;
1818

1919
try {
@@ -34,14 +34,21 @@ module.exports = [
3434
}
3535
// pick the report based on its name
3636
let result = {};
37+
let embedUrl = null;
3738
const project = { id: projectId };
3839
switch (reportName) {
3940
case 'summary':
40-
result = await lookerSerivce.generateEmbedUrl(req.authUser, project, member, '/embed/looks/1');
41+
embedUrl = '/embed/looks/1';
42+
break;
43+
case 'mock':
44+
embedUrl = config.lookerConfig.MOCK_EMBED_REPORT;
4145
break;
4246
default:
4347
return res.status(404).send('Report not found');
4448
}
49+
if (embedUrl) {
50+
result = await lookerSerivce.generateEmbedUrl(req.authUser, project, member, embedUrl);
51+
}
4552

4653
req.log.debug(result);
4754
return res.status(200).json(result);

0 commit comments

Comments
 (0)