Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
feat(exports): export location graph
Browse files Browse the repository at this point in the history
  • Loading branch information
KZavorotna authored Jul 22, 2022
1 parent 1fb8aa1 commit 68c2388
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/index.html

Large diffs are not rendered by default.

26 changes: 25 additions & 1 deletion src/models/export-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,19 @@ interface AnalyticsQueryContent {
widgetName: string;
}

type Content = AllContent | MeasurementFilterContent | AnalyticsQueryContent;
interface ChartContent {
type: 'chart',
from: Date;
to: Date;
highResolution: boolean;
series: {
quantityHashId: string;
pinHashId: string;
}[];
title: string;
}

type Content = AllContent | MeasurementFilterContent | AnalyticsQueryContent | ChartContent;
const contentSchemaAlternatives = [
Joi.object().keys({
type: Joi.string().required().valid('all').example('all'),
Expand All @@ -46,6 +58,17 @@ const contentSchemaAlternatives = [
dashboardId: Joi.string().required().example('xd2rd4'),
widgetName: Joi.string().required().example('Widget name'),
}),
Joi.object().keys({
type: Joi.string().required().valid('chart').example('chart'),
from: Joi.date().required().example('2019-12-31T15:23Z'),
to: Joi.date().required().example('2021-01-01T00:00Z').description('Up to not including'),
series: Joi.array().max(40).items(Joi.object().keys({
pinHashId: Joi.string().required().example('e13d57'),
quantityHashId: Joi.string().required().example('sajia1'),
})).required(),
highResolution: Joi.boolean().default(false),
title: Joi.string().required().example('Chart name'),
}),
];

const schema = Joi.object().keys({
Expand Down Expand Up @@ -77,6 +100,7 @@ export {
AllContent,
MeasurementFilterContent,
AnalyticsQueryContent,
ChartContent,
Content,
contentSchemaAlternatives,
};
15 changes: 13 additions & 2 deletions src/routes/settings/add-export.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Joi from 'joi';
import { ControllerGeneratorOptionsWithClient } from '../../comms/controller';
import { AllContent, AnalyticsQueryContent } from '../../models/export-request';
import { AllContent, AnalyticsQueryContent, ChartContent } from '../../models/export-request';
import { schema as analyticsQuerySchema } from '../../models/analytics-query';

interface MeasurementFilterContentByHashId {
Expand All @@ -11,7 +11,7 @@ interface MeasurementFilterContentByHashId {
// AllContent is still a reference to settings/add-export.ts
interface Request {
body: {
content: AllContent | MeasurementFilterContentByHashId | AnalyticsQueryContent;
content: AllContent | MeasurementFilterContentByHashId | AnalyticsQueryContent | ChartContent;
delimiter: ',' | ';';
rowDelimiter: '\n' | '\r\n';
};
Expand Down Expand Up @@ -43,6 +43,17 @@ const controllerGeneratorOptions: ControllerGeneratorOptionsWithClient = {
dashboardId: Joi.string().required().example('xd2rd4'),
widgetName: Joi.string().required().example('Widget name'),
}).required(),
Joi.object().keys({
type: Joi.string().required().valid('chart').example('chart'),
from: Joi.date().required().example('2019-12-31T15:23Z'),
to: Joi.date().required().example('2021-01-01T00:00Z').description('Up to not including'),
series: Joi.array().max(40).items(Joi.object().keys({
pinHashId: Joi.string().required().example('e13d57'),
quantityHashId: Joi.string().required().example('sajia1'),
})).required(),
highResolution: Joi.boolean().default(false),
title: Joi.string().required().example('Chart name'),
}),
).required(),
delimiter: Joi.string().valid(',', ';').required().example(','),
rowDelimiter: Joi.string().valid('\n', '\r\n').required().example('\n'),
Expand Down

0 comments on commit 68c2388

Please sign in to comment.