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 ArbitraryResourceMetadata metadata;
|
||||||
|
|
||||||
public Long size;
|
public Long size;
|
||||||
|
public Long created;
|
||||||
|
public Long updated;
|
||||||
|
|
||||||
public ArbitraryResourceInfo() {
|
public ArbitraryResourceInfo() {
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,10 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
|||||||
StringBuilder sql = new StringBuilder(512);
|
StringBuilder sql = new StringBuilder(512);
|
||||||
List<Object> bindParams = new ArrayList<>();
|
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) {
|
if (service != null) {
|
||||||
sql.append(" AND service = ");
|
sql.append(" AND service = ");
|
||||||
@ -426,7 +429,7 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
|||||||
bindParams.add(queryWildcard);
|
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) {
|
if (reverse != null && reverse) {
|
||||||
sql.append(" DESC");
|
sql.append(" DESC");
|
||||||
@ -445,6 +448,8 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
|||||||
Service serviceResult = Service.valueOf(resultSet.getInt(2));
|
Service serviceResult = Service.valueOf(resultSet.getInt(2));
|
||||||
String identifierResult = resultSet.getString(3);
|
String identifierResult = resultSet.getString(3);
|
||||||
Integer sizeResult = resultSet.getInt(4);
|
Integer sizeResult = resultSet.getInt(4);
|
||||||
|
long dateCreated = resultSet.getLong(5);
|
||||||
|
long dateUpdated = resultSet.getLong(6);
|
||||||
|
|
||||||
// We should filter out resources without names
|
// We should filter out resources without names
|
||||||
if (nameResult == null) {
|
if (nameResult == null) {
|
||||||
@ -456,6 +461,8 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
|||||||
arbitraryResourceInfo.service = serviceResult;
|
arbitraryResourceInfo.service = serviceResult;
|
||||||
arbitraryResourceInfo.identifier = identifierResult;
|
arbitraryResourceInfo.identifier = identifierResult;
|
||||||
arbitraryResourceInfo.size = Longs.valueOf(sizeResult);
|
arbitraryResourceInfo.size = Longs.valueOf(sizeResult);
|
||||||
|
arbitraryResourceInfo.created = dateCreated;
|
||||||
|
arbitraryResourceInfo.updated = dateUpdated;
|
||||||
|
|
||||||
arbitraryResources.add(arbitraryResourceInfo);
|
arbitraryResources.add(arbitraryResourceInfo);
|
||||||
} while (resultSet.next());
|
} while (resultSet.next());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user