8355-testToMaster #3336

Merged
alexm merged 241 commits from 8355-testToMaster into master 2025-01-07 06:44:57 +00:00
6 changed files with 13 additions and 20 deletions
Showing only changes of commit e279cc4b47 - Show all commits

View File

@ -23,8 +23,8 @@ module.exports = Self => {
Self.optimize = async addressIds => {
const models = Self.app.models;
try {
const locationiqConfig = await models.LocationiqConfig.findOne();
if (!locationiqConfig) throw new UserError(`LocationIQ service is not configured`);
const osrmConfig = await models.OsrmConfig.findOne();
if (!osrmConfig) throw new UserError(`OSRM service is not configured`);
let coords = [];
for (const addressId of addressIds) {
@ -39,10 +39,9 @@ module.exports = Self => {
.map(coord => `${coord.longitude},${coord.latitude}`)
.join(';');
const response = await axios.post(`
${locationiqConfig.url}optimize/driving/${concatCoords}?key=${locationiqConfig.key}
${osrmConfig.url}/trip/v1/driving/${concatCoords}
`);
const tolerance = locationiqConfig.tolerance;
const tolerance = osrmConfig.tolerance;
for (waypoint of response.data.waypoints) {
const longitude = waypoint.location[0];
const latitude = waypoint.location[1];

View File

@ -88,7 +88,7 @@
"Language": {
"dataSource": "vn"
},
"LocationiqConfig": {
"OsrmConfig": {
"dataSource": "vn"
},
"Machine": {

View File

@ -1,4 +0,0 @@
module.exports = Self => {
require('../methods/locationiq-config/optimize')(Self);
};

View File

@ -0,0 +1,4 @@
module.exports = Self => {
require('../methods/osrm-config/optimize')(Self);
};

View File

@ -1,9 +1,9 @@
{
"name": "LocationiqConfig",
"name": "OsrmConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "locationiqConfig"
"table": "osrmConfig"
}
},
"properties": {
@ -16,10 +16,6 @@
"type": "string",
"required": true
},
"key": {
"type": "string",
"required": true
},
"tolerance": {
"type": "number",
"required": false

View File

@ -1,9 +1,7 @@
CREATE TABLE `vn`.`locationiqConfig` (
CREATE TABLE `vn`.`osrmConfig` (
`id` int(10) unsigned NOT NULL,
`url` varchar(100) NOT NULL COMMENT 'Dirección base de la API',
`key` varchar(100) NOT NULL COMMENT 'Access token',
`tolerance` decimal(6,6) NOT NULL DEFAULT 0 COMMENT 'Tolerancia entre las coordenadas enviadas y las retornadas',
`maxCoordsRequest` int(10) unsigned DEFAULT NULL COMMENT 'Número máximo de coordenadas por petición',
PRIMARY KEY (`id`),
CONSTRAINT `locationiqConfig_check` CHECK (`id` = 1)
CONSTRAINT `osrmConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;