fix: Fix tracking issues and remove active_load from user model

This commit is contained in:
Josepablo C
2024-10-11 20:47:39 -06:00
parent 46de083c41
commit ded1760923
7 changed files with 50 additions and 67 deletions

View File

@@ -22,6 +22,7 @@ const getById = async(req, res) => {
const elementId = req.params.id;
const select = [
"categories",
"shipment_code",
"truck_type",
"published_date",
"createdAt",
@@ -31,11 +32,13 @@ const getById = async(req, res) => {
"est_loading_date",
"est_unloading_date",
"origin.city",
"origin_geo",
"origin.state",
"origin.lat",
"origin.lng",
"destination.city",
"destination.state",
"destination_geo",
"destination.lat",
"destination.lng",
];
// const load = await Model.findOne( { _id : elementId , load_status : "Transit" } , select ).populate( populate_list );
const load = await Model.findById( elementId , select ).populate( populate_list );

View File

@@ -1,46 +1,40 @@
"use strict";
const { getPagination , getPage } = require( '../../../lib/Misc' );
const { GenericHandler } = require( '../../../lib/Handlers/Generic.handler' );
const Model = require( '../../../lib/Models/loads.model.js' );
const categoriesModel = require( '../../../lib/Models/product-categories.model' );
const populate_list = [
'categories',
{
path:'vehicle',
select:"last_location_lat last_location_lng last_location_geo last_location_time background_tracking"
}
];
// last_location_lat
// last_location_lng
// last_location_geo
// last_location_time
// background_tracking
const generic = new GenericHandler( Model, null, populate_list );
const getList = async(req, res) => {
try{
const filter = { status : "Published" };
const select = [
"shipment_code",
"categories",
"truck_type",
"published_date",
"createdAt",
"status",
"weight",
"est_loading_date",
"est_unloading_date",
"origin",
"destination"
];
const { page , elements } = getPagination( req.query );
const retVal = await generic.getList(page , elements, filter, select );
res.send( retVal );
}catch(error){
console.error( error );
return res.status( 500 ).send({ error: error.message });
}
};
module.exports = { getList };
"use strict";
const { getPagination , getPage } = require( '../../../lib/Misc' );
const { GenericHandler } = require( '../../../lib/Handlers/Generic.handler' );
const Model = require( '../../../lib/Models/loads.model.js' );
const categoriesModel = require( '../../../lib/Models/product-categories.model' );
const populate_list = [ 'categories' ];
// last_location_lat
// last_location_lng
// last_location_geo
// last_location_time
// background_tracking
const generic = new GenericHandler( Model, null, populate_list );
const getList = async(req, res) => {
try{
const filter = { status : "Published" };
const select = [
"shipment_code",
"categories",
"truck_type",
"published_date",
"createdAt",
"status",
"weight",
"est_loading_date",
"est_unloading_date",
"origin",
"destination"
];
const { page , elements } = getPagination( req.query );
const retVal = await generic.getList(page , elements, filter, select );
res.send( retVal );
}catch(error){
console.error( error );
return res.status( 500 ).send({ error: error.message });
}
};
module.exports = { getList };

View File

@@ -40,7 +40,8 @@ const getListPublished = async(req, res) => {
const getListLocations = async(req, res) => {
const filter = { status : "Free" };
const select = [
"last_location_geo",
"last_location_lat",
"last_location_lng",
"driver",
"updatedAt",
"status",