Enhance data distribution and filtering by adding 'tags' to allowed filters and updating publish functionality
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit modifies the `distributeUpdate` function in `utils.js` to include the `_id` in the published object, improving data integrity during distribution. Additionally, it updates the allowed filters in the `products` and `clients` routes to include 'tags', enhancing the filtering capabilities for better data categorization and retrieval.
This commit is contained in:
parent
efcf1389a5
commit
9b896c2157
@ -16,6 +16,7 @@ const listAllowedFilters = [
|
||||
'price',
|
||||
'margin',
|
||||
'priceWithTax',
|
||||
'tags',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference',
|
||||
@ -33,7 +34,7 @@ const listAllowedSorters = [
|
||||
'priceWithTax',
|
||||
'updatedAt',
|
||||
];
|
||||
const propertiesAllowedFilters = [];
|
||||
const propertiesAllowedFilters = ['tags'];
|
||||
import {
|
||||
listProductsRouteHandler,
|
||||
getProductRouteHandler,
|
||||
|
||||
@ -5,7 +5,15 @@ import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = ['country', 'active', 'createdAt', 'updatedAt', 'name', '_reference'];
|
||||
const listAllowedFilters = [
|
||||
'country',
|
||||
'active',
|
||||
'tags',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'name',
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'name',
|
||||
'country',
|
||||
@ -16,7 +24,7 @@ const listAllowedSorters = [
|
||||
'updatedAt',
|
||||
'_id',
|
||||
];
|
||||
const propertiesAllowedFilters = ['country', 'active', 'createdAt', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['country', 'active', 'tags', 'createdAt', 'updatedAt'];
|
||||
import {
|
||||
listClientsRouteHandler,
|
||||
getClientRouteHandler,
|
||||
|
||||
@ -1404,7 +1404,7 @@ function filterDistributeKeys(value, keys = DISTRIBUTE_KEYS) {
|
||||
}
|
||||
|
||||
async function distributeUpdate(value, id, type) {
|
||||
await natsServer.publish(`${type}s.${id}.object`, value);
|
||||
await natsServer.publish(`${type}s.${id}.object`, { ...value, _id: id });
|
||||
}
|
||||
|
||||
async function distributeStats(value, type) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user