forked from Qortal/qortal
Added optional "before" and "after" params to GET /arbitrary/resources/search
This commit is contained in:
parent
8fa344125c
commit
0ec661431c
@ -367,6 +367,8 @@ let res = await qortalRequest({
|
|||||||
nameListFilter: "QApp1234Subscriptions", // Optional - will only return results if they are from a name included in supplied list
|
nameListFilter: "QApp1234Subscriptions", // Optional - will only return results if they are from a name included in supplied list
|
||||||
followedOnly: false, // Optional - include followed names only
|
followedOnly: false, // Optional - include followed names only
|
||||||
excludeBlocked: false, // Optional - exclude blocked content
|
excludeBlocked: false, // Optional - exclude blocked content
|
||||||
|
// before: 1683546000000, // Optional - limit to resources created before timestamp
|
||||||
|
// after: 1683546000000, // Optional - limit to resources created after timestamp
|
||||||
limit: 100,
|
limit: 100,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
reverse: true
|
reverse: true
|
||||||
|
@ -175,6 +175,8 @@ public class ArbitraryResource {
|
|||||||
@Parameter(description = "Exclude blocked content") @QueryParam("excludeblocked") Boolean excludeBlocked,
|
@Parameter(description = "Exclude blocked content") @QueryParam("excludeblocked") Boolean excludeBlocked,
|
||||||
@Parameter(description = "Include status") @QueryParam("includestatus") Boolean includeStatus,
|
@Parameter(description = "Include status") @QueryParam("includestatus") Boolean includeStatus,
|
||||||
@Parameter(description = "Include metadata") @QueryParam("includemetadata") Boolean includeMetadata,
|
@Parameter(description = "Include metadata") @QueryParam("includemetadata") Boolean includeMetadata,
|
||||||
|
@Parameter(description = "Creation date before timestamp") @QueryParam("before") Long before,
|
||||||
|
@Parameter(description = "Creation date after timestamp") @QueryParam("after") Long after,
|
||||||
@Parameter(ref = "limit") @QueryParam("limit") Integer limit,
|
@Parameter(ref = "limit") @QueryParam("limit") Integer limit,
|
||||||
@Parameter(ref = "offset") @QueryParam("offset") Integer offset,
|
@Parameter(ref = "offset") @QueryParam("offset") Integer offset,
|
||||||
@Parameter(ref = "reverse") @QueryParam("reverse") Boolean reverse) {
|
@Parameter(ref = "reverse") @QueryParam("reverse") Boolean reverse) {
|
||||||
@ -203,8 +205,9 @@ public class ArbitraryResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<ArbitraryResourceData> resources = repository.getArbitraryRepository()
|
List<ArbitraryResourceData> resources = repository.getArbitraryRepository()
|
||||||
.searchArbitraryResources(service, query, identifier, names, title, description, usePrefixOnly, exactMatchNames,
|
.searchArbitraryResources(service, query, identifier, names, title, description, usePrefixOnly,
|
||||||
defaultRes, followedOnly, excludeBlocked, includeMetadata, includeStatus, limit, offset, reverse);
|
exactMatchNames, defaultRes, followedOnly, excludeBlocked, includeMetadata, includeStatus,
|
||||||
|
before, after, limit, offset, reverse);
|
||||||
|
|
||||||
if (resources == null) {
|
if (resources == null) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
@ -39,7 +39,7 @@ public interface ArbitraryRepository {
|
|||||||
|
|
||||||
public List<ArbitraryResourceData> getArbitraryResources(Service service, String identifier, List<String> names, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Boolean includeMetadata, Boolean includeStatus, Integer limit, Integer offset, Boolean reverse) throws DataException;
|
public List<ArbitraryResourceData> getArbitraryResources(Service service, String identifier, List<String> names, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Boolean includeMetadata, Boolean includeStatus, Integer limit, Integer offset, Boolean reverse) throws DataException;
|
||||||
|
|
||||||
public List<ArbitraryResourceData> searchArbitraryResources(Service service, String query, String identifier, List<String> names, String title, String description, boolean prefixOnly, List<String> namesFilter, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Boolean includeMetadata, Boolean includeStatus, Integer limit, Integer offset, Boolean reverse) throws DataException;
|
public List<ArbitraryResourceData> searchArbitraryResources(Service service, String query, String identifier, List<String> names, String title, String description, boolean prefixOnly, List<String> namesFilter, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Boolean includeMetadata, Boolean includeStatus, Long before, Long after, Integer limit, Integer offset, Boolean reverse) throws DataException;
|
||||||
|
|
||||||
|
|
||||||
// Arbitrary resources cache save/load
|
// Arbitrary resources cache save/load
|
||||||
|
@ -640,7 +640,7 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
|||||||
@Override
|
@Override
|
||||||
public List<ArbitraryResourceData> searchArbitraryResources(Service service, String query, String identifier, List<String> names, String title, String description, boolean prefixOnly,
|
public List<ArbitraryResourceData> searchArbitraryResources(Service service, String query, String identifier, List<String> names, String title, String description, boolean prefixOnly,
|
||||||
List<String> exactMatchNames, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked,
|
List<String> exactMatchNames, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked,
|
||||||
Boolean includeMetadata, Boolean includeStatus, Integer limit, Integer offset, Boolean reverse) throws DataException {
|
Boolean includeMetadata, Boolean includeStatus, Long before, Long after, Integer limit, Integer offset, Boolean reverse) throws DataException {
|
||||||
StringBuilder sql = new StringBuilder(512);
|
StringBuilder sql = new StringBuilder(512);
|
||||||
List<Object> bindParams = new ArrayList<>();
|
List<Object> bindParams = new ArrayList<>();
|
||||||
|
|
||||||
@ -724,6 +724,16 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
|||||||
sql.append(")");
|
sql.append(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Timestamp range
|
||||||
|
if (before != null) {
|
||||||
|
sql.append(" AND created_when < ?");
|
||||||
|
bindParams.add(before);
|
||||||
|
}
|
||||||
|
if (after != null) {
|
||||||
|
sql.append(" AND created_when > ?");
|
||||||
|
bindParams.add(after);
|
||||||
|
}
|
||||||
|
|
||||||
// Handle "followed only"
|
// Handle "followed only"
|
||||||
if (followedOnly != null && followedOnly) {
|
if (followedOnly != null && followedOnly) {
|
||||||
List<String> followedNames = ListUtils.followedNames();
|
List<String> followedNames = ListUtils.followedNames();
|
||||||
|
@ -228,6 +228,8 @@ window.addEventListener("message", (event) => {
|
|||||||
if (data.nameListFilter != null) url = url.concat("&namefilter=" + data.nameListFilter);
|
if (data.nameListFilter != null) url = url.concat("&namefilter=" + data.nameListFilter);
|
||||||
if (data.followedOnly != null) url = url.concat("&followedonly=" + new Boolean(data.followedOnly).toString());
|
if (data.followedOnly != null) url = url.concat("&followedonly=" + new Boolean(data.followedOnly).toString());
|
||||||
if (data.excludeBlocked != null) url = url.concat("&excludeblocked=" + new Boolean(data.excludeBlocked).toString());
|
if (data.excludeBlocked != null) url = url.concat("&excludeblocked=" + new Boolean(data.excludeBlocked).toString());
|
||||||
|
if (data.before != null) url = url.concat("&before=" + data.before);
|
||||||
|
if (data.after != null) url = url.concat("&after=" + data.after);
|
||||||
if (data.limit != null) url = url.concat("&limit=" + data.limit);
|
if (data.limit != null) url = url.concat("&limit=" + data.limit);
|
||||||
if (data.offset != null) url = url.concat("&offset=" + data.offset);
|
if (data.offset != null) url = url.concat("&offset=" + data.offset);
|
||||||
if (data.reverse != null) url = url.concat("&reverse=" + new Boolean(data.reverse).toString());
|
if (data.reverse != null) url = url.concat("&reverse=" + new Boolean(data.reverse).toString());
|
||||||
|
Loading…
Reference in New Issue
Block a user