Skip to content

Commit

Permalink
Rename column
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Sep 6, 2023
1 parent d9380f6 commit 4416482
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion superset-frontend/src/dashboard/actions/hydrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const hydrateDashboard =
owners: slice.owners,
modified: slice.modified,
changed_on: new Date(slice.changed_on).getTime(),
outdated: slice.outdated,
force_save: slice.force_save,
};

sliceIds.add(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ class Chart extends React.Component {
this.setState({ descriptionHeight });
}

if (this.props.slice.outdated) {
if (this.props.slice.force_save) {
const { slice, updateSlices } = this.props;
SupersetClient.put({
endpoint: `/api/v1/chart/${slice.slice_id}`,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query_context: slice.query_context,
params: JSON.stringify(slice.form_data),
outdated: false,
force_save: false,
}),
}).then(response =>
updateSlices({
Expand Down Expand Up @@ -391,7 +391,6 @@ class Chart extends React.Component {
}

render() {
console.log(this.props.slice.outdated);
const {
id,
componentId,
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/explore/actions/saveModalActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const getSlicePayload = (
ownState: null,
}),
),
outdated: false,
force_save: false,
};
return payload;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ const ExploreChartPanel = ({
ensureIsArray(chart.queriesResponse).length > 0;

/* When feature flags are toggled we might need to resave the chart to update all
* required parameters. This can be done by setting `Slice.outdated` to false in a
* required parameters. This can be done by setting `Slice.force_save` to false in a
* migration or manually. */
const updateChart = useCallback(
async function overwriteChart() {
if (slice.outdated) {
if (slice.force_save) {
await actions.updateSlice(slice, slice.slice_name);
// TODO (betodealmeida): better refresh logic
window.location.reload();
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/types/Chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export type Slice = {
query_context?: object;
is_managed_externally: boolean;
owners?: number[];
outdated?: boolean;
force_save?: boolean;
};

export default Chart;
4 changes: 2 additions & 2 deletions superset/charts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]:
"viz_type",
"query_context",
"is_managed_externally",
"outdated",
"force_save",
"tags.id",
"tags.name",
"tags.type",
Expand Down Expand Up @@ -195,7 +195,7 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]:
"thumbnail_url",
"url",
"viz_type",
"outdated",
"force_save",
"tags.id",
"tags.name",
"tags.type",
Expand Down
4 changes: 2 additions & 2 deletions superset/charts/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class ChartEntityResponseSchema(Schema):
description_markeddown = fields.String(
metadata={"description": description_markeddown_description}
)
outdated = fields.Boolean(
force_save = fields.Boolean(
metadata={
"description": "Does the chart need to be re-saved to update metadata?"
}
Expand Down Expand Up @@ -290,7 +290,7 @@ class ChartPutSchema(Schema):
is_managed_externally = fields.Boolean(allow_none=True, dump_default=False)
external_url = fields.String(allow_none=True)
tags = fields.Nested(TagSchema, many=True)
outdated = fields.Boolean(
force_save = fields.Boolean(
metadata={
"description": "Does the chart need to be re-saved to update metadata?"
}
Expand Down
2 changes: 1 addition & 1 deletion superset/explore/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class SliceSchema(Schema):
slice_id = fields.Integer(metadata={"description": "The slice ID."})
slice_name = fields.String(metadata={"description": "The slice name."})
slice_url = fields.String(metadata={"description": "The slice URL."})
oudated = fields.Boolean(
force_save = fields.Boolean(
metadata={
"description": "Does the chart need to be re-saved to update metadata?"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""Add outdated column to charts
"""Add force_save column to charts
Revision ID: 122965576ebd
Revises: ec54aca4c8a2
Expand All @@ -33,9 +33,9 @@
def upgrade():
op.add_column(
"slices",
sa.Column("outdated", sa.Boolean(), nullable=True, default=False),
sa.Column("force_save", sa.Boolean(), nullable=True, default=False),
)


def downgrade():
op.drop_column("slices", "outdated")
op.drop_column("slices", "force_save")
4 changes: 2 additions & 2 deletions superset/models/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class Slice( # pylint: disable=too-many-public-methods

# force the chart to re-save itself; this is useful when the backend has missing
# information that can only be computed by the frontend
outdated = Column(Boolean, nullable=True, default=False)
force_save = Column(Boolean, nullable=True, default=False)

token = ""

Expand Down Expand Up @@ -251,7 +251,7 @@ def data(self) -> dict[str, Any]:
"certified_by": self.certified_by,
"certification_details": self.certification_details,
"is_managed_externally": self.is_managed_externally,
"outdated": self.outdated,
"force_save": self.force_save,
}

@property
Expand Down

0 comments on commit 4416482

Please sign in to comment.