Pdf optimization
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-09-14 11:44:10 +02:00
parent 279120dd03
commit 7043b833d0
3 changed files with 14 additions and 9 deletions

View File

@ -1,4 +1,5 @@
const fs = require('fs-extra'); const fs = require('fs-extra');
const path = require('path');
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development'; let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
let configPath = `/etc/salix`; let configPath = `/etc/salix`;
@ -12,8 +13,9 @@ let configFiles = [
]; ];
for (let configFile of configFiles) { for (let configFile of configFiles) {
if (fs.existsSync(configFile)) { const filePath = path.join(__dirname, configFile);
const conf = require(configFile); if (fs.existsSync(filePath)) {
const conf = require(filePath);
for (let prop in conf) for (let prop in conf)
Object.assign(config[prop], conf[prop]); Object.assign(config[prop], conf[prop]);
} }

View File

@ -27,7 +27,7 @@ class Report extends Component {
if (fs.existsSync(fullPath)) if (fs.existsSync(fullPath))
options = require(optionsPath); options = require(optionsPath);
const page = await config.browser.newPage(); const page = (await config.browser.pages())[0];
await page.emulateMedia('screen'); await page.emulateMedia('screen');
await page.setContent(template); await page.setContent(template);

View File

@ -10,12 +10,15 @@ module.exports = {
const routes = await this.fetchRoutes(routesId); const routes = await this.fetchRoutes(routesId);
const tickets = await this.fetchTickets(routesId); const tickets = await this.fetchTickets(routesId);
for (let route of routes) { const map = new Map();
const routeTickets = tickets.filter(ticket => {
return ticket.routeFk == route.id;
});
route.tickets = routeTickets; for (let route of routes)
map.set(route.id, route);
for (let ticket of tickets) {
const route = map.get(ticket.routeFk);
if (!route.tickets) route.tickets = [];
route.tickets.push(ticket);
} }
this.routes = routes; this.routes = routes;
@ -61,7 +64,7 @@ module.exports = {
a.postalCode, a.postalCode,
LPAD(a.id, 5, '0') AS addressFk, LPAD(a.id, 5, '0') AS addressFk,
p.name province, p.name province,
vn.ticketGetTotal(t.id) AS import, 0 AS import,
am.name ticketAgency, am.name ticketAgency,
tob.description, tob.description,
s.shipFk, s.shipFk,