feat: Add extra filter to observers to only return valid loads
This commit is contained in:
@@ -45,10 +45,8 @@ function getAndFilterList( query ){
|
||||
const {
|
||||
company,
|
||||
carrier,
|
||||
status,
|
||||
posted_by,
|
||||
posted_by_name,
|
||||
load_status,
|
||||
published_date,
|
||||
loaded_date,
|
||||
transit_date,
|
||||
@@ -63,10 +61,8 @@ function getAndFilterList( query ){
|
||||
|
||||
if( company ){ filter_list.push( { company } ); }
|
||||
if( carrier ){ filter_list.push( { carrier } ); }
|
||||
if( status ){ filter_list.push( { status } ); }
|
||||
if( posted_by ) { filter_list.push({ posted_by }); }
|
||||
if( posted_by_name ) { filter_list.push({ posted_by_name }); }
|
||||
if( load_status ) { filter_list.push({ load_status }); }
|
||||
if( published_date ) { filter_list.push({ published_date }); }
|
||||
if( loaded_date ) { filter_list.push({ loaded_date }); }
|
||||
if( transit_date ) { filter_list.push({ transit_date }); }
|
||||
@@ -122,11 +118,14 @@ async function findList( user_type, email, query ) {
|
||||
throw "Invalid user_type";
|
||||
}
|
||||
|
||||
let filter;
|
||||
|
||||
const { $sort } = query;
|
||||
const { page, elements } = getPagination( query );
|
||||
const andFilterList = getAndFilterList( query ) || [];
|
||||
|
||||
let filter;
|
||||
andFilterList.push({ "status": "Published" }); // Only when the publication is not in draft or completed.
|
||||
andFilterList.push({ "bidder": { "$ne":null } }); // Only when published have a proposal accepted.
|
||||
|
||||
if( user_type == "client" ){
|
||||
andFilterList.push({ "alert_list" : email });
|
||||
@@ -179,7 +178,6 @@ const Warehouse_findList = async(req, res) => {
|
||||
try{
|
||||
const { email, user_type } = req.context;
|
||||
const query = req.query || {};
|
||||
console.log( email, user_type );
|
||||
res.send( await findList( user_type, email, query ) );
|
||||
}catch(error){
|
||||
console.error( error );
|
||||
|
||||
Reference in New Issue
Block a user