I have a file storage structure
folder
file
I want a count of files per folder
So I add the aggregate count to do this - easy.
However, the aggregate count is cached and not refreshed when the data changes (files folder changes). So if I do something like - change files folder then the count doesn’t change on the page.
My setup was:
repeating group of folders with each row doing a “search for files:count”
The user usually only has 20 folders so this method seemed the simplest and cleanest way to handle getting the file count but it has issues due to caching. The caching seems to only be an issue within a repeating group since doing “search:count” outside a repeating group works fine.
I tried many methods to force the count to refresh - clear data, reload data etc - none work. Only a page reload resets it.
So now I have to store the count as a field on the data. This creates WU overhang just to update this simple number that is rarely used in the app (would be much more efficient to count it only when needed for this 1 repeating group).
search : count = 0.3 + 0.2 wu
= 0.5wu on each page load that has the count
instead I have to update the folder each time the underlying data changes on the file. This creates 3 trigger points:
1 - previous folder removed
2 - new folder added
3 - file deleted (only want to count active files)
Fine - I can add database triggers for those actions.
So now I have 2 database triggers
1 - folder changed on file (updates old and new folder counts)
2 - file deleted
Each time it then recalcs the aggregate on the folder so:
search:count = 0.3 + 0.2 wu
- server side workflow write action = 0.6wu
total = 1.1 wu per update
Now if the user transfers 1000 files from folder A to folder B
The database trigger is triggered 1000 times
The folder aggregate search is redone 2000 times (1 for old and 1 for new folder)
The database trigger also has WU overhand of 0.05 wu when ANY FIELD is changed.
total = 2210 w (assuming 1000 files moved to a new folder)
It would be much more performant to just run the aggregate search once on page load when viewing the folder. Yet I have to build a multi layered system to keep the count updated just so I can show a list of folders with file counts to the user.
Is this really the only way to achieve this aggregate count in a way that isn’t cached for the user?