Add the "getNumberOfPayloadsForDatasource" endpoint.

This commit is contained in:
Lampros Smyrnaios 2023-04-24 09:54:35 +03:00
parent 1b14a7e554
commit d7797eaaf6
2 changed files with 21 additions and 1 deletions

View File

@ -10,8 +10,10 @@ The database used is the [Impala](https://impala.apache.org/).<br>
This endpoint returns the total number of payloads existing in the database, independently of the way they were aggregated. This includes the payloads created by other pieces of software, before the PDF-Aggregation-Service was created.
- "**getNumberOfPayloadsAggregatedByService**" endpoint: **http://<IP>:<PORT>/api/stats/getNumberOfPayloadsAggregatedByService** <br>
This endpoint returns the number of payloads aggregated by the PDF-Aggregated-Service itself. It excludes the payloads aggregated by other methods, by applying a Date-filter for the records created in 2021 or later.
- "**getNumberOfPayloadsForDatasource**" endpoint: **http://<IP>:<PORT>/api/stats/getNumberOfPayloadsForDatasource?datasourceId="givenDatasourceId"** <br>
This endpoint returns the number of payloads which belong to the datasource specified by the given datasourceID.
- "**getNumberOfRecordsInspected**" endpoint: **http://<IP>:<PORT>/api/stats/getNumberOfRecordsInspected** <br>
This endpoint returns the number of records inspected by the PDF-Aggregation-Service.
This endpoint returns the number of records inspected by the PDF-Aggregation-Service.
<br>
<br>

View File

@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
@ -48,6 +49,23 @@ public class StatsController {
}
/**
* This endpoint returns the number of payloads related to the given datasourceID.
* */
@GetMapping("getNumberOfPayloadsForDatasource")
public ResponseEntity<?> getNumberOfPayloadsForDatasource(@RequestParam String datasourceId) {
logger.info("Received a \"getNumberOfPayloadsForDatasource\" request.");
final String getPayloadsNumberForDatasourceQuery =
"select count(p.id) from " + ImpalaConnector.databaseName + ".payload p\n" +
" join " + ImpalaConnector.databaseName + ".publication pu on pu.id=p.id and pu.datasourceid=\"" + datasourceId + "\"";
logger.trace("getPayloadsNumberForDatasourceQuery:\n" + getPayloadsNumberForDatasourceQuery);
return statsService.getNumberOfPayloads(getPayloadsNumberForDatasourceQuery, "related to datasourceId \"" + datasourceId + "\"");
}
/**
* This endpoint returns the number of records inspected by the PDF-Aggregation-Service.
* */