ShotgunModel._refresh_data() doesn't update view

I think i’m missing something dumb :blush:

I’m working on an app that needs to refresh ShotgunModel data on a regular interval to display updates from SG. It’s my understanding if you call _refresh_data(), the model will check SG and then refresh the view automatically if anything needs to be updated. But perhaps I’m missing something?

        self._delivery_model = ShotgunDeliveryModel(self)
        self.ui.deliveriesView.setModel(self._delivery_model)
        self._delivery_model._load_data(
            entity_type="Delivery",
            hierarchy=["title"],
            filters=[
                ["sg_delivery_method", "in", ["Aspera Files", "Aspera Package", "Box"]],
                ["sg_delivery_type", "is_not", "Shipment"],
                ["created_at", "in_last", [1, "DAY"]],
            ],
            fields=["title", "id", "sg_status_list", "sg_delivery_progress", "addressings_to", "created_at"],
            columns=["id", "sg_status_list", "sg_delivery_progress", "addressings_to", "created_at"],
            order=[{"field_name": "created_at", "direction": "desc"}],
        )

My initial call to _load_data() is working fine. And I can see that calls to _refresh_data() “succeed” in updating the model when data has changed or been added, but the view is only refreshed if the title value changes.

It is not refreshed if any of the other values queried change in SG, nor if any new rows are added.

Here’s an output from the logs when one of the other (non-title) fields changes:

2023-08-02 17:41:00,067 [10688 INFO sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] Data already cached. Refreshing Delivery Monitor...
2023-08-02 17:41:00,266 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunDeliveryModel] --> ShotGrid data arrived. (12 records)
2023-08-02 17:41:00,268 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunDeliveryModel] Updating data model with new shotgun data...
2023-08-02 17:41:00,269 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler] Updating <ShotgunFindDataHandler@/Users/kp/Library/Caches/Shotgun/wba/site/fw-shotgunutils/sg/Delivery/ad3ee58be36931c6d6b2500e34b41a6a/22c7306e82b97f78bfa391e9982ae9fd.27 (12 items)> with 12 shotgun records.
2023-08-02 17:41:00,271 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler] Hierarchy: ['title']
2023-08-02 17:41:00,272 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler] sanitizing data...
2023-08-02 17:41:00,274 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler] ...done!
2023-08-02 17:41:00,275 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler] Generating new tree in memory...
2023-08-02 17:41:00,276 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler] Diffing new tree against old tree...
2023-08-02 17:41:00,316 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler] ShotGrid data (12 records) received and processed. 
2023-08-02 17:41:00,318 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler]     The new tree is 12 records.
2023-08-02 17:41:00,319 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler]     There were 1 diffs from in-memory cache:
2023-08-02 17:41:00,320 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler]     Number of new records: 0
2023-08-02 17:41:00,322 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler]     Number of deleted records: 0
2023-08-02 17:41:00,323 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler]     Number of modified records: 1
2023-08-02 17:41:00,324 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] update_data: 0.044990s
2023-08-02 17:41:00,324 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunDeliveryModel] ShotGrid data contained 1 modifications
2023-08-02 17:41:00,325 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunDeliveryModel] Begin applying diffs to model...
2023-08-02 17:41:00,326 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunDeliveryModel] Processing change {'data': <ShotgunItemData uid:184763>, 'mode': 0}
2023-08-02 17:41:00,327 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunDeliveryModel] Updating model item <ShotgunStandardItem XXXX_XXXX_Vendor Submission_20230802_01>
2023-08-02 17:41:00,327 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunDeliveryModel] ...diffs applied!
2023-08-02 17:41:00,328 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunDeliveryModel] Begin asynchronously saving cache to disk
2023-08-02 17:41:00,329 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler] Saving to disk: <ShotgunFindDataHandler@/Users/kp/Library/Caches/Shotgun/wba/site/fw-shotgunutils/sg/Delivery/ad3ee58be36931c6d6b2500e34b41a6a/22c7306e82b97f78bfa391e9982ae9fd.27 (12 items)>
2023-08-02 17:41:00,330 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunFindDataHandler] Completed save of <ShotgunFindDataHandler@/Users/kp/Library/Caches/Shotgun/wba/site/fw-shotgunutils/sg/Delivery/ad3ee58be36931c6d6b2500e34b41a6a/22c7306e82b97f78bfa391e9982ae9fd.27 (12 items)>. Size 3733 bytes
2023-08-02 17:41:00,330 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] save_cache: 0.001179s
2023-08-02 17:41:00,367 [10688 DEBUG sgtk.ext.tkimpc26dbae2e7e54e8abc85bfdf608ac88c.tk_desktop.site_communication] [PROXY] [ShotgunDeliveryModel] Asynchronous cache save complete.

Thanks
p