Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
feat: adds data overview to metadata as well as version of library us…
Browse files Browse the repository at this point in the history
…ed to export data
  • Loading branch information
Enngage committed Apr 8, 2020
1 parent 1cda6e2 commit f09a3fa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/cli/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const backupAsync = async (config: ICliFileConfig) => {
const response = await exportService.exportAllAsync();
await zipService.createZipAsync(response);

if (exportContainsInconsistencies(report, config)) {
if (exportContainsInconsistencies(report)) {
const logFilename: string = getLogFilename(config.zipFilename);

await fileHelper.createFileInCurrentFolderAsync(logFilename, JSON.stringify(report));
Expand Down Expand Up @@ -143,16 +143,12 @@ const process = async () => {
}
};

const exportContainsInconsistencies = (projectReport: ProjectContracts.IProjectReportResponseContract, config: ICliFileConfig) => {
const exportContainsInconsistencies = (projectReport: ProjectContracts.IProjectReportResponseContract) => {
const projectHasIssues = projectReport.variant_issues.length > 0 || projectReport.type_issues.length > 0;
if (!projectHasIssues) {
return true;
}

if (config.force === true) {
return true;
}

return false;
};

Expand Down
13 changes: 13 additions & 0 deletions src/export/export.models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,22 @@ export interface IExportData {
}

export interface IExportMetadata {
version: string;
projectId: string;
timestamp: Date;
isInconsistentExport: boolean;
dataOverview: IExportMetadataDataOverview;
}

export interface IExportMetadataDataOverview {
taxonomiesCount: number;
contentTypeSnippetsCount: number;
contentTypesCount: number;
contentItemsCount: number;
languageVariantsCount: number;
languagesCount: number;
assetsCount: number;
assetFoldersCount: number;
}

export interface IExportAllResult {
Expand Down
16 changes: 14 additions & 2 deletions src/export/export.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {

import { IExportAllResult, IExportConfig, IExportData } from './export.models';
import { ItemType } from '../core';
import { version } from '../../package.json';

export class ExportService {
private readonly client: IManagementClient;
Expand All @@ -37,14 +38,25 @@ export class ExportService {
languageVariants: await this.exportLanguageVariantsAsync(contentTypes.map(m => m.id)),
assets: await this.exportAssetsAsync(),
languages: await this.exportLanguagesAsync(),
assetFolders: await this.exportAssetFoldersAsync()
assetFolders: await this.exportAssetFoldersAsync(),
};

return {
metadata: {
version,
timestamp: new Date(),
projectId: this.config.projectId,
isInconsistentExport: projectValidation.type_issues.length > 0 || projectValidation.variant_issues.length > 0
isInconsistentExport: projectValidation.type_issues.length > 0 || projectValidation.variant_issues.length > 0,
dataOverview: {
assetFoldersCount: data.assetFolders.length,
assetsCount: data.assets.length,
contentItemsCount: data.contentItems.length,
contentTypeSnippetsCount: data.contentTypeSnippets.length,
contentTypesCount: data.contentTypes.length,
languageVariantsCount: data.languageVariants.length,
languagesCount: data.languages.length,
taxonomiesCount: data.taxonomies.length,
},
},
validation: projectValidation,
data
Expand Down

0 comments on commit f09a3fa

Please sign in to comment.