--[[----------------------------------------------------------------------------

WFCatSortByRecentlyEdited.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2021 Adobe Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remains the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe
Incorporated and its suppliers and are protected by all applicable
intellectual property laws, including trade secret and copyright laws.
Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Incorporated.

----------------------------------------------------------------------------]]--

--==============================================================================

local WFCatSortByRecentlyEdited = {}

--------------------------------------------------------------------------------

function WFCatSortByRecentlyEdited.executeSort( wfCatalog, assetLocalIds, order )
		
	if order ~= "ASC" then
		order = "DESC"
	end

	local sqlString = string.format(
			[[ SELECT editedDate.docId  
				FROM editedDate 
				WHERE editedDate.docId IN CARRAY(?, ?, 'int32') 
				ORDER BY editedDate.completeTime %s, editedDate.docId %s ]],
				order, order )

	return wfCatalog:indexStore():query( {
			sql = sqlString,
			calm = 1,
			assetLocalIds,
			#assetLocalIds
		} )
	
end

--==============================================================================

return WFCatSortByRecentlyEdited
