We've been looking at using the JS API for some specialised updating screens which don't need the full power of Simple Edit mode - they only need a single metadata value to be changed. However, this still appears to require loading the full metadata to check the existing value, and loading each asset's metadata individually.
We've tried using getMetadata and getKeywordsReplacements with the one field we require, but there is no difference in speed - they both take about half a second per asset, which is far too slow.
Is there a way of retrieving a specific metadata field for a given asset which is faster than this?
Similarly, setting a single metadata value is taking approximately 30 seconds, which is ridiculous. Any ideas as to why this should be so slow?
Why not just use triggers and standard metadata keywords instead? I think the JS API might be an overkill here.
[quote]
Similarly, setting a single metadata value is taking approximately 30 seconds, which is ridiculous. Any ideas as to why this should be so slow?
[/quote]
This isn't representative of normal speed when using this function on a healthy system. Perhaps there are some server or DB issues?
[quote]
Is there a way of retrieving a specific metadata field for a given asset which is faster than this?
[/quote]
You could look into the batchRequest function if you were going to pursue running multiple JS API calls in one go. Otherwise Nic's suggestion is probably the way to go.
Ideally, we would be generating a table, with a series of checkboxes, clicking the check boxes to indicate the metadata value, then submitting the whole lot and changing all the selected values in one call. However, Squiz doesn't appear to provide this basic functionality, so the JS API calls are an attempt to replicate the functionality - it's easy to use Javascript to provide the table and check boxes, and multiple values can be set in a single screen, with background calls making it seem like multiple values are being set at once, assuming the speed can be improved.
We can't currently use batch mode, since it's not in the version of Squiz we've got (although we are due an upgrade within the next fortnight), and whilst there may be database issues, we can't check these until we get performance indicators with the upgrade.
[quote]
We can't currently use batch mode, since it's not in the version of Squiz we've got (although we are due an upgrade within the next fortnight), and whilst there may be database issues, we can't check these until we get performance indicators with the upgrade.
[/quote]
In that case I should also mention there were significant performance enhancements added to a lot of the JS API functions during the development of EES phase 3 (roughly Matrix 4.4.1+). I'm not sure if the metadata functions were a part of that but I'm guessing it won't be much of an issue if you are upgrading anyway.