Add filter function

This commit is contained in:
hodasemi 2024-04-20 08:55:10 +02:00
parent 0dd46385cd
commit f04b0bff0d
2 changed files with 28 additions and 3 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.~lock.*

View file

@ -385,9 +385,9 @@ function findAll(object) {
return list; return list;
} }
app.get('/ddtrust/cepi/:rights', async (request, response) => { async function resultList(cb_filter, rights) {
// read parameters from DB and only return accessible // read parameters from DB and only return accessible
let deviceParameters = await queryDevice("%Cepi%", convert_rights(request.params.rights)); let deviceParameters = await queryDevice(cb_filter, convert_rights(rights));
// read paremeter description file // read paremeter description file
let descriptions = JSON.parse(fs.readFileSync('resources/variable_description.json', 'utf8')); let descriptions = JSON.parse(fs.readFileSync('resources/variable_description.json', 'utf8'));
@ -398,7 +398,31 @@ app.get('/ddtrust/cepi/:rights', async (request, response) => {
// combine description information with parameters queried from DB // combine description information with parameters queried from DB
let result = await createResultList(deviceParameters, descriptions, calculations); let result = await createResultList(deviceParameters, descriptions, calculations);
response.json(result) return result;
}
app.get('/ddtrust/cepi/:rights', async (request, response) => {
let result_list = await resultList("%Cepi%", request.params.rights);
response.json(result_list)
})
app.get('ddtrust/cepi/:rights/filter', async (request, response) => {
let result_list = await resultList("%Cepi%", request.params.rights);
// column | variable name
// ----------------------
// B | finished_product
// C | base_material
// D | coating
// E | fillers
// F | polymers
// G | artificial_fibre
// H | ???
// I | printed
// J | varnish
// K | glue
// L | sealing
}) })
app.listen(PORT, () => { app.listen(PORT, () => {