bertrandmartel / tableau-scraping

Tableau scraper python library. R and Python scripts to scrape data from Tableau viz
MIT License
131 stars 21 forks source link

Zones don't always update when there are story points #66

Open nickgrasley opened 2 years ago

nickgrasley commented 2 years ago

There's a bug with the updateFullData method of the TableauWorkbook class. Starting at line 82, it tries to update the zones with any new zone data in the cmdResponse:

if ("applicationPresModel" in cmdResponse["vqlCmdResponse"]["layoutStatus"]):
    presModel = cmdResponse["vqlCmdResponse"]["layoutStatus"]["applicationPresModel"]
    newZones = utils.getZones(presModel)
    newZonesStorage = {}
    for zone in newZones.keys():
        if newZones[zone] is not None:
            zoneHasVizdata = utils.hasVizData(newZones[zone])
            if (not zoneHasVizdata) and (zone in self._scraper.zones):
                newZonesStorage[zone] = copy.deepcopy(
                    self._scraper.zones[zone])
            else:
                newZonesStorage[zone] = copy.deepcopy(newZones[zone])
    self._scraper.zones = newZonesStorage
else:
    self._scraper.zones = {}

However, it doesn't update zones if there is no vizData field present and the zones already exist. Story points never have a vizData field, so the workbook will never update the zones despite the worksheet zones within the story point changing.

This bug arises when iterating over 2 or more parameters within a story point. The code should probably also check whether the underlying worksheet zones have the vizData field and update the zones if they do.

(For those interested in a quick fix, I changed the if statement on line 89 to check if the zone is a story point)

if (not zoneHasVizdata) and (zone in self._scraper.zones) and not ("presModelHolder" in newZones[zone] and "flipboard" in newZones[zone]["presModelHolder"] and "storyPoints" in newZones[zone]["presModelHolder"]["flipboard"]):