getredash / redash-toolbelt

API client and utilities to manage a Redash instance
BSD 2-Clause "Simplified" License
140 stars 74 forks source link

Fix visualizations command in redash-migrate #71

Closed ariarijp closed 3 years ago

ariarijp commented 3 years ago

What type of PR is this? (check all applicable)

Description

It will fix a bug in visualizations command in redash-migrate.

Steps to reproduce the bug

Running redash-migrate visualizations twice will break meta.json.

first time,

{
...snip...
    "visualizations": {
        "3": 4,
        "4": 5,
        "5": 7
    },
    "dashboards": {},
    "alerts": {},
    "flags": {
        "viz_import_complete": {
            "3": true,
            "4": true
        }
    },
...snip...

then, run again,

{
...snip...
    "visualizations": {
        "3": 4,
        "4": 5,
        "5": 7
    },
    "dashboards": {},
    "alerts": {},
    "flags": {
        "viz_import_complete": {
            "3": true,
            "4": true,
            "3": true, <- existing keys are appeared.
            "4": true
        }
    },
...snip...
ariarijp commented 3 years ago

Hi, @susodapop

I think this change should be good for redash-migrate users. Could you review it? or if you don't want to apply this change, please feel free to close it.

Thank you

susodapop commented 3 years ago

Thanks for this suggestion. I incorporated a fix for this issue in #102. The ideal way to fix this is to avoid the type cast issues with meta.json altogether since we already have the tooling in place to coerce types with cast_keys_to_int.

That said, it accomplishes the same thing. Now you can re-run redash-migrate visualizations idempotently.