mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-27 18:07:57 +00:00
Add V2 API for counting total datasets (#938)
This commit is contained in:
parent
e25ae33d40
commit
675a8e0f68
@ -17,6 +17,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import wherehows.dao.table.DictDatasetDao;
|
||||
@ -95,7 +96,7 @@ public class DatasetViewDao extends BaseViewDao {
|
||||
return view;
|
||||
}
|
||||
|
||||
public PagedCollection<DatasetView> listDatasets(@Nonnull String platform, @Nonnull String prefix, int start,
|
||||
public PagedCollection<DatasetView> listDatasets(@Nullable String platform, @Nonnull String prefix, int start,
|
||||
int count) throws Exception {
|
||||
throw new RuntimeException("Not implemented yet");
|
||||
}
|
||||
|
||||
@ -80,6 +80,19 @@ public class Dataset extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public static Promise<Result> totalDatasets() {
|
||||
try {
|
||||
String platform = request().getQueryString("platform");
|
||||
String prefix = StringUtils.defaultIfBlank(request().getQueryString("prefix"), "");
|
||||
|
||||
return Promise.promise(
|
||||
() -> ok(String.valueOf(DATASET_VIEW_DAO.listDatasets(platform, prefix, 0, 1).getTotal())));
|
||||
} catch (Exception e) {
|
||||
Logger.error("Fail to count total datasets", e);
|
||||
return Promise.promise(() -> internalServerError("Fetch data Error: " + e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static Promise<Result> getComplianceDataTypes() {
|
||||
try {
|
||||
return Promise.promise(() -> ok(
|
||||
|
||||
@ -270,6 +270,12 @@ GET /api/v2/dataset/listNames
|
||||
|
||||
GET /api/v2/dataset/listDatasets controllers.api.v2.Dataset.listDatasets()
|
||||
|
||||
GET /api/v2/dataset/totalDatasets controllers.api.v2.Dataset.totalDatasets()
|
||||
|
||||
GET /api/v2/list/platforms controllers.api.v2.Dataset.getDataPlatforms()
|
||||
|
||||
GET /api/v2/list/complianceDataTypes controllers.api.v2.Dataset.getComplianceDataTypes()
|
||||
|
||||
# Map static resources from the /public folder to the /assets URL path
|
||||
GET /assets/*file controllers.Assets.at(path="/public", file)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user