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

chore: Removes unused vars #20194

Merged
merged 3 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ import {
import { DASHBOARD_LIST } from '../dashboard_list/dashboard_list.helper';
import { CHART_LIST } from '../chart_list/chart_list.helper';

const getTestTitle = (
test: Mocha.Suite = (Cypress as any).mocha.getRunner().suite.ctx.test,
): string =>
test.parent?.title
? `${getTestTitle(test.parent)} -- ${test.title}`
: test.title;

// TODO: fix flaky init logic and re-enable
const milliseconds = new Date().getTime();
const dashboard = `Test Dashboard${milliseconds}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Dashboard save action', () => {
beforeEach(() => {
cy.login();
cy.visit(WORLD_HEALTH_DASHBOARD);
cy.get('#app').then(data => {
cy.get('#app').then(() => {
cy.get('.dashboard-header-container').then(headerContainerElement => {
const dashboardId = headerContainerElement.attr('data-test-id');

Expand All @@ -57,7 +57,7 @@ describe('Dashboard save action', () => {

// change to what the title should be
it('should save as new dashboard', () => {
cy.wait('@copyRequest').then(xhr => {
cy.wait('@copyRequest').then(() => {
cy.get('[data-test="editable-title"]').then(element => {
const dashboardTitle = element.attr('title');
expect(dashboardTitle).to.not.equal(`World Bank's Data`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { PostProcessingContribution } from '@superset-ui/core';
import { PostProcessingFactory } from './types';

export const contributionOperator: PostProcessingFactory<PostProcessingContribution> =
(formData, queryObject) => {
formData => {
michael-s-molina marked this conversation as resolved.
Show resolved Hide resolved
if (formData.contributionMode) {
return {
operation: 'contribution',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
import { PostProcessingFlatten } from '@superset-ui/core';
import { PostProcessingFactory } from './types';

export const flattenOperator: PostProcessingFactory<PostProcessingFlatten> = (
formData,
queryObject,
) => ({
operation: 'flatten',
});
michael-s-molina marked this conversation as resolved.
Show resolved Hide resolved
michael-s-molina marked this conversation as resolved.
Show resolved Hide resolved
export const flattenOperator: PostProcessingFactory<PostProcessingFlatten> =
() => ({
operation: 'flatten',
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,22 @@ import {
} from '@superset-ui/core';
import { PostProcessingFactory } from './types';

export const prophetOperator: PostProcessingFactory<PostProcessingProphet> = (
formData,
queryObject,
) => {
const index = getColumnLabel(formData.x_axis || DTTM_ALIAS);
michael-s-molina marked this conversation as resolved.
Show resolved Hide resolved
michael-s-molina marked this conversation as resolved.
Show resolved Hide resolved
if (formData.forecastEnabled) {
return {
operation: 'prophet',
options: {
time_grain: formData.time_grain_sqla,
periods: parseInt(formData.forecastPeriods, 10),
confidence_interval: parseFloat(formData.forecastInterval),
yearly_seasonality: formData.forecastSeasonalityYearly,
weekly_seasonality: formData.forecastSeasonalityWeekly,
daily_seasonality: formData.forecastSeasonalityDaily,
index,
},
};
}
return undefined;
};
export const prophetOperator: PostProcessingFactory<PostProcessingProphet> =
formData => {
const index = getColumnLabel(formData.x_axis || DTTM_ALIAS);
if (formData.forecastEnabled) {
return {
operation: 'prophet',
options: {
time_grain: formData.time_grain_sqla,
periods: parseInt(formData.forecastPeriods, 10),
confidence_interval: parseFloat(formData.forecastInterval),
yearly_seasonality: formData.forecastSeasonalityYearly,
weekly_seasonality: formData.forecastSeasonalityWeekly,
daily_seasonality: formData.forecastSeasonalityDaily,
index,
},
};
}
return undefined;
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
import { PostProcessingResample } from '@superset-ui/core';
import { PostProcessingFactory } from './types';

export const resampleOperator: PostProcessingFactory<PostProcessingResample> = (
formData,
queryObject,
) => {
const resampleZeroFill = formData.resample_method === 'zerofill';
const resampleMethod = resampleZeroFill ? 'asfreq' : formData.resample_method;
michael-s-molina marked this conversation as resolved.
Show resolved Hide resolved
const resampleRule = formData.resample_rule;
if (resampleMethod && resampleRule) {
return {
operation: 'resample',
options: {
method: resampleMethod,
rule: resampleRule,
fill_value: resampleZeroFill ? 0 : null,
},
};
}
return undefined;
};
export const resampleOperator: PostProcessingFactory<PostProcessingResample> =
formData => {
const resampleZeroFill = formData.resample_method === 'zerofill';
const resampleMethod = resampleZeroFill
? 'asfreq'
: formData.resample_method;
const resampleRule = formData.resample_rule;
if (resampleMethod && resampleRule) {
return {
operation: 'resample',
options: {
method: resampleMethod,
rule: resampleRule,
fill_value: resampleZeroFill ? 0 : null,
},
};
}
return undefined;
};
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ const time_range: SharedControlConfig<'DateFilterControl'> = {
"using the engine's local timezone. Note one can explicitly set the timezone " +
'per the ISO 8601 format if specifying either the start and/or end time.',
),
mapStateToProps: ({ datasource, form_data }) => ({
mapStateToProps: ({ datasource }) => ({
datasource,
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,7 @@ import { QueryContext, QueryObject } from './types/Query';
import { SetDataMaskHook } from '../chart';
import { JsonObject } from '../connection';

const WRAP_IN_ARRAY = (
baseQueryObject: QueryObject,
options?: {
extras?: {
cachedChanges?: any;
};
ownState?: JsonObject;
hooks?: {
setDataMask: SetDataMaskHook;
setCachedChanges: (newChanges: any) => void;
};
},
) => [baseQueryObject];
const WRAP_IN_ARRAY = (baseQueryObject: QueryObject) => [baseQueryObject];

export type BuildFinalQueryObjects = (
baseQueryObject: QueryObject,
Expand All @@ -53,23 +41,11 @@ export default function buildQueryContext(
}
| BuildFinalQueryObjects,
): QueryContext {
const {
queryFields,
buildQuery = WRAP_IN_ARRAY,
hooks = {},
ownState = {},
} = typeof options === 'function'
? { buildQuery: options, queryFields: {} }
: options || {};
const queries = buildQuery(buildQueryObject(formData, queryFields), {
extras: {},
ownState,
hooks: {
setDataMask: () => {},
setCachedChanges: () => {},
...hooks,
},
});
const { queryFields, buildQuery = WRAP_IN_ARRAY } =
typeof options === 'function'
? { buildQuery: options, queryFields: {} }
: options || {};
const queries = buildQuery(buildQueryObject(formData, queryFields));
queries.forEach(query => {
if (Array.isArray(query.post_processing)) {
// eslint-disable-next-line no-param-reassign
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import ModalTrigger from 'src/components/ModalTrigger';
import { EmptyWrapperType } from 'src/components/TableView/TableView';

interface EstimateQueryCostButtonProps {
dbId: number;
schema: string;
sql: string;
getEstimate: Function;
queryCostEstimate: Record<string, any>;
selectedText?: string;
Expand All @@ -37,9 +34,6 @@ interface EstimateQueryCostButtonProps {
}

const EstimateQueryCostButton = ({
dbId,
schema,
sql,
getEstimate,
queryCostEstimate = {},
selectedText,
Expand Down
3 changes: 0 additions & 3 deletions superset-frontend/src/SqlLab/components/SqlEditor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -691,9 +691,6 @@ class SqlEditor extends React.PureComponent {
this.props.database.allows_cost_estimate && (
<span>
<EstimateQueryCostButton
dbId={qe.dbId}
schema={qe.schema}
sql={qe.sql}
getEstimate={this.getQueryCostEstimate}
queryCostEstimate={qe.queryCostEstimate}
selectedText={qe.selectedText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ class SliceHeaderControls extends React.PureComponent<
downloadAsImage(
getScreenshotNodeSelector(this.props.slice.slice_id),
this.props.slice.slice_name,
{},
true,
// @ts-ignore
)(domEvent).then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,36 +146,6 @@ const FilterTitleContainer = forwardRef<HTMLDivElement, Props>(
</FilterTitle>
);
};
const recursivelyRender = (
elementId: string,
nodeList: Array<{ id: string; parentId: string | null }>,
rendered: Array<string>,
): React.ReactNode => {
const didAlreadyRender = rendered.indexOf(elementId) >= 0;
if (didAlreadyRender) {
return null;
}
let parent = null;
const element = nodeList.filter(el => el.id === elementId)[0];
if (!element) {
return null;
}

rendered.push(elementId);
if (element.parentId) {
parent = recursivelyRender(element.parentId, nodeList, rendered);
}
const children = nodeList
.filter(item => item.parentId === elementId)
.map(item => recursivelyRender(item.id, nodeList, rendered));
return (
<>
{parent}
{renderComponent(elementId)}
{children}
</>
);
};

const renderFilterGroups = () => {
const items: React.ReactNode[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { buildQueryContext, QueryFormData } from '@superset-ui/core';
* if a viz needs multiple different result sets.
*/
export default function buildQuery(formData: QueryFormData) {
return buildQueryContext(formData, baseQueryObject => [
return buildQueryContext(formData, () => [
{
result_type: 'columns',
columns: [],
Expand Down
6 changes: 3 additions & 3 deletions superset-frontend/src/middleware/asyncEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ const wsConnect = (): void => {
if (lastReceivedEventId) url += `?last_id=${lastReceivedEventId}`;
ws = new WebSocket(url);

ws.addEventListener('open', event => {
ws.addEventListener('open', () => {
logging.log('WebSocket connected');
clearTimeout(wsConnectTimeout);
wsConnectRetries = 0;
});

ws.addEventListener('close', event => {
ws.addEventListener('close', () => {
wsConnectTimeout = setTimeout(() => {
wsConnectRetries += 1;
if (wsConnectRetries <= wsConnectMaxRetries) {
Expand All @@ -251,7 +251,7 @@ const wsConnect = (): void => {
}, wsConnectErrorDelay);
});

ws.addEventListener('error', event => {
ws.addEventListener('error', () => {
// https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/readyState
if (ws.readyState < 2) ws.close();
});
Expand Down
3 changes: 1 addition & 2 deletions superset-frontend/src/utils/downloadAsImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import { SyntheticEvent } from 'react';
import domToImage, { Options } from 'dom-to-image';
import domToImage from 'dom-to-image';
import kebabCase from 'lodash/kebabCase';
import { t } from '@superset-ui/core';
import { addWarningToast } from 'src/components/MessageToasts/actions';
Expand Down Expand Up @@ -50,7 +50,6 @@ const generateFileStem = (description: string, date = new Date()) =>
export default function downloadAsImage(
selector: string,
description: string,
domToImageOptions: Options = {},
isExactSelector = false,
) {
return (event: SyntheticEvent) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ const SqlAlchemyTab = ({
onInputChange,
testConnection,
conf,
isEditMode = false,
testInProgress = false,
}: {
db: DatabaseObject | null;
onInputChange: EventHandler<ChangeEvent<HTMLInputElement>>;
testConnection: EventHandler<MouseEvent<HTMLElement>>;
conf: { SQLALCHEMY_DOCS_URL: string; SQLALCHEMY_DISPLAY_TEXT: string };
isEditMode?: boolean;
testInProgress?: boolean;
}) => {
let fallbackDocsUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,6 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
}
conf={conf}
testConnection={testConnection}
isEditMode={isEditMode}
testInProgress={testInProgress}
/>
{isDynamic(db?.backend || db?.engine) && !isEditMode && (
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/views/CRUD/data/query/QueryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const StyledPopoverItem = styled.div`
color: ${({ theme }) => theme.colors.grayscale.dark2};
`;

function QueryList({ addDangerToast, addSuccessToast }: QueryListProps) {
function QueryList({ addDangerToast }: QueryListProps) {
const {
state: { loading, resourceCount: queryCount, resourceCollection: queries },
fetchData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ const StyledPopoverItem = styled.div`
function SavedQueryList({
addDangerToast,
addSuccessToast,
user,
}: SavedQueryListProps) {
const {
state: {
Expand Down