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',
|
'price',
|
||||||
'margin',
|
'margin',
|
||||||
'priceWithTax',
|
'priceWithTax',
|
||||||
|
'tags',
|
||||||
'createdAt',
|
'createdAt',
|
||||||
'updatedAt',
|
'updatedAt',
|
||||||
'_reference',
|
'_reference',
|
||||||
@ -33,7 +34,7 @@ const listAllowedSorters = [
|
|||||||
'priceWithTax',
|
'priceWithTax',
|
||||||
'updatedAt',
|
'updatedAt',
|
||||||
];
|
];
|
||||||
const propertiesAllowedFilters = [];
|
const propertiesAllowedFilters = ['tags'];
|
||||||
import {
|
import {
|
||||||
listProductsRouteHandler,
|
listProductsRouteHandler,
|
||||||
getProductRouteHandler,
|
getProductRouteHandler,
|
||||||
|
|||||||
@ -5,7 +5,15 @@ import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
|||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
const listAllowedFilters = ['country', 'active', 'createdAt', 'updatedAt', 'name', '_reference'];
|
const listAllowedFilters = [
|
||||||
|
'country',
|
||||||
|
'active',
|
||||||
|
'tags',
|
||||||
|
'createdAt',
|
||||||
|
'updatedAt',
|
||||||
|
'name',
|
||||||
|
'_reference',
|
||||||
|
];
|
||||||
const listAllowedSorters = [
|
const listAllowedSorters = [
|
||||||
'name',
|
'name',
|
||||||
'country',
|
'country',
|
||||||
@ -16,7 +24,7 @@ const listAllowedSorters = [
|
|||||||
'updatedAt',
|
'updatedAt',
|
||||||
'_id',
|
'_id',
|
||||||
];
|
];
|
||||||
const propertiesAllowedFilters = ['country', 'active', 'createdAt', 'updatedAt'];
|
const propertiesAllowedFilters = ['country', 'active', 'tags', 'createdAt', 'updatedAt'];
|
||||||
import {
|
import {
|
||||||
listClientsRouteHandler,
|
listClientsRouteHandler,
|
||||||
getClientRouteHandler,
|
getClientRouteHandler,
|
||||||
|
|||||||
@ -1404,7 +1404,7 @@ function filterDistributeKeys(value, keys = DISTRIBUTE_KEYS) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function distributeUpdate(value, id, type) {
|
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) {
|
async function distributeStats(value, type) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user