photools.com Community

IMatch Discussion Boards => IMatch Scripting and Apps => Topic started by: ben on December 29, 2021, 11:35:42 AM

Title: Sort order in /files and /attributes
Post by: ben on December 29, 2021, 11:35:42 AM
Hello,

i am currently debugging a script and it basically does what it should.
I am combining the information from two endpoints v1/files and v1/attributes.
For v1/attributes i am also sending the parameter "returnempty" so that both returned lists have the same length.

I get all the information i need, but the returned array of both endpoints are not in the same order.
Is this the way it works?
For example, do the first entries of v1/files and v1/attributes not refer to the same file?

My python payloads i am using with request.get() are as follows:
payloadFiles = {'idlist':'@imatch.filewindow.active.selection', 'fields': 'id,ext,size,filename', 'auth_token':auth}
payloadAttr  = {'idlist':'@imatch.filewindow.active.selection', 'set': 'PIV', 'attributes': 'Orig_vidStart,Orig_vidEnd', 'returnempty': True , 'auth_token':auth}

Returned data is:
files[0] = {'id': 83764, ...}        from v1/attributes
files[1] = {'id': 83765, ...}

result[0] = {'id': 83765, ...}        from v1/attributes
result[1] = {'id': 83764, ...}


Thanks for any clarification
Ben
Title: Re: Sort order in /files and /attributes
Post by: Mario on December 29, 2021, 12:27:01 PM
Use the sortprofile or sortby parameter to control the sort order.
Title: Re: Sort order in /files and /attributes
Post by: ben on December 29, 2021, 07:18:46 PM
Quote from: Mario on December 29, 2021, 12:27:01 PM
Use the sortprofile or sortby parameter to control the sort order.
How do i use the sortby parameter?
I checked the following sources but only find somehow similar parameters:

  - https://www.photools.com/dev-center/doc/imatch/tutorial-recipes.html
  - IMatch WebServices™ Documentation
Title: Re: Sort order in /files and /attributes
Post by: Mario on December 29, 2021, 07:52:35 PM
These are for the /files endpoint.
Title: Re: Sort order in /files and /attributes
Post by: ben on December 30, 2021, 03:49:09 PM
Sorry, i don't understand what you mean.
Can i use the sortby parameter for both endpoints /files and /attributes?
Where do i find its documentation?
Title: Re: Sort order in /files and /attributes
Post by: Mario on December 30, 2021, 05:08:03 PM
All parameters available for endpoints are documented in the IMWS Documentation App (available via the App Manager), e.g. for the /files endpoint:

(https://www.photools.com/community/index.php?action=dlattach;topic=12139.0;attach=28689;image)
Title: Re: Sort order in /files and /attributes
Post by: ben on January 02, 2022, 11:28:43 PM
I read the documentation again. The sortby parameter is only listet for /files but not for /attributes.
If i run the sample commands from the documentation in the browser, then the /files endpoint considers the sortby parameter. But the /attributes doesn't.
This is all consistent.

So now i am back to my initial question.
How can i combine information from /files and /attributes? If they cannot be sorted the same way, then there is no simple way.
I could of course loop through all IDs of /files and then search for the corresponding ID in /attributes.

I can live with this workaround, i just wanted to get confirmation if thats the way it is.
Title: Re: Sort order in /files and /attributes
Post by: Mario on January 03, 2022, 12:02:55 AM
You have only what the endpoints support.
Just retrieve both sets and reconcile as needed by your application. Sorting stuff in Python is easy, so this should be not much of a burden.
Title: Re: Sort order in /files and /attributes
Post by: ben on January 03, 2022, 10:13:23 AM
ok thanks, that answers my initial question.