forked from Qortal/qortal
Include "created" and "updated" timestamps in GET /arbitrary/resource/* API endpoints.
This commit is contained in:
parent
c78593cf15
commit
ea2577d1c3
@ -16,6 +16,8 @@ public class ArbitraryResourceInfo {
|
||||
public ArbitraryResourceMetadata metadata;
|
||||
|
||||
public Long size;
|
||||
public Long created;
|
||||
public Long updated;
|
||||
|
||||
public ArbitraryResourceInfo() {
|
||||
}
|
||||
|
@ -383,7 +383,10 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
||||
StringBuilder sql = new StringBuilder(512);
|
||||
List<Object> bindParams = new ArrayList<>();
|
||||
|
||||
sql.append("SELECT name, service, identifier, MAX(size) AS max_size FROM ArbitraryTransactions WHERE 1=1");
|
||||
sql.append("SELECT name, service, identifier, MAX(size) AS max_size, MIN(created_when) AS date_created, MAX(created_when) AS date_updated " +
|
||||
"FROM ArbitraryTransactions " +
|
||||
"JOIN Transactions USING (signature) " +
|
||||
"WHERE 1=1");
|
||||
|
||||
if (service != null) {
|
||||
sql.append(" AND service = ");
|
||||
@ -426,7 +429,7 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
||||
bindParams.add(queryWildcard);
|
||||
}
|
||||
|
||||
sql.append(" GROUP BY name, service, identifier ORDER BY name COLLATE SQL_TEXT_UCC_NO_PAD");
|
||||
sql.append(" GROUP BY name, service, identifier ORDER BY date_created");
|
||||
|
||||
if (reverse != null && reverse) {
|
||||
sql.append(" DESC");
|
||||
@ -445,6 +448,8 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
||||
Service serviceResult = Service.valueOf(resultSet.getInt(2));
|
||||
String identifierResult = resultSet.getString(3);
|
||||
Integer sizeResult = resultSet.getInt(4);
|
||||
long dateCreated = resultSet.getLong(5);
|
||||
long dateUpdated = resultSet.getLong(6);
|
||||
|
||||
// We should filter out resources without names
|
||||
if (nameResult == null) {
|
||||
@ -456,6 +461,8 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
||||
arbitraryResourceInfo.service = serviceResult;
|
||||
arbitraryResourceInfo.identifier = identifierResult;
|
||||
arbitraryResourceInfo.size = Longs.valueOf(sizeResult);
|
||||
arbitraryResourceInfo.created = dateCreated;
|
||||
arbitraryResourceInfo.updated = dateUpdated;
|
||||
|
||||
arbitraryResources.add(arbitraryResourceInfo);
|
||||
} while (resultSet.next());
|
||||
|
Loading…
Reference in New Issue
Block a user