Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tr-pull-datapoints should filter status based on category and includeGuessedCategories flag #386

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Transcend Inc.",
"name": "@transcend-io/cli",
"description": "Small package containing useful typescript utilities.",
"version": "6.14.3",
"version": "6.15.0",
"homepage": "https://github.com/transcend-io/cli",
"repository": {
"type": "git",
Expand Down
14 changes: 10 additions & 4 deletions src/data-inventory/pullAllDatapoints.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable max-lines */
import keyBy from 'lodash/keyBy';
import {
DataCategoryType,
type DataCategoryType,
SubDataPointDataSubCategoryGuessStatus,
} from '@transcend-io/privacy-types';
import uniq from 'lodash/uniq';
Expand All @@ -14,12 +14,12 @@ import type { GraphQLClient } from 'graphql-request';
import {
DATAPOINT_EXPORT,
DATA_SILO_EXPORT,
DataSiloAttributeValue,
type DataSiloAttributeValue,
SUB_DATA_POINTS_COUNT,
makeGraphQLRequest,
} from '../graphql';
import { logger } from '../logger';
import { DataCategoryInput, ProcessingPurposeInput } from '../codecs';
import type { DataCategoryInput, ProcessingPurposeInput } from '../codecs';
import { mapSeries } from 'bluebird';

export interface DataSiloCsvPreview {
Expand Down Expand Up @@ -119,6 +119,12 @@ async function pullSubDatapoints(
const filterBy = {
...(parentCategories.length > 0 ? { category: parentCategories } : {}),
...(subCategories.length > 0 ? { subCategoryIds: subCategories } : {}),
// if parentCategories or subCategories and not includeGuessedCategories
...(parentCategories.length + subCategories.length > 0 &&
!includeGuessedCategories
? // then only show data points with approved data categories
{ status: SubDataPointDataSubCategoryGuessStatus.Approved }
: {}),
...(dataSiloIds.length > 0 ? { dataSilos: dataSiloIds } : {}),
};

Expand All @@ -140,7 +146,7 @@ async function pullSubDatapoints(
progressBar.start(totalCount, 0);
let total = 0;
let shouldContinue = false;
let cursor;
let cursor: string | undefined;
let offset = 0;
do {
try {
Expand Down