Do not distribute

This commit is contained in:
Douglas Barone 2023-08-04 10:39:12 -04:00
parent 986dccfd90
commit b856c62616
2 changed files with 4 additions and 8 deletions

View File

@ -3,7 +3,6 @@ import { Request, Response, Router } from 'express'
import { hasRolesMiddleware } from '../middlewares/hasRolesMiddleware.js' import { hasRolesMiddleware } from '../middlewares/hasRolesMiddleware.js'
import { prisma } from '../prisma.js' import { prisma } from '../prisma.js'
import { distributedCopy } from '../utils/distributedCopy.js'
import { PrinterStatusService } from '../services/PrinterStatusService.js' import { PrinterStatusService } from '../services/PrinterStatusService.js'
import log from '../log.js' import log from '../log.js'
@ -52,7 +51,7 @@ class PrinterController {
static async show(req: Request, res: Response) { static async show(req: Request, res: Response) {
const { serialNumber } = req.params const { serialNumber } = req.params
const { take = 32, days = 60 } = req.query const { days = 60 } = req.query
const gte = new Date(Date.now() - 1000 * 60 * 60 * 24 * Number(days)) const gte = new Date(Date.now() - 1000 * 60 * 60 * 24 * Number(days))
@ -82,7 +81,7 @@ class PrinterController {
res.json({ res.json({
...printer, ...printer,
avgMonthPrint, avgMonthPrint,
status: distributedCopy(printer.status, Number(take)) status: printer.status
}) })
} else res.status(400).json({ error: 'Printer not found' }) } else res.status(400).json({ error: 'Printer not found' })
} }

View File

@ -2,7 +2,6 @@ import { Router, Request, Response } from 'express'
import { prisma } from '../prisma.js' import { prisma } from '../prisma.js'
import { PrinterStatusService } from '../services/PrinterStatusService.js' import { PrinterStatusService } from '../services/PrinterStatusService.js'
import { hasRolesMiddleware } from '../middlewares/hasRolesMiddleware.js' import { hasRolesMiddleware } from '../middlewares/hasRolesMiddleware.js'
import { distributedCopy } from '../utils/distributedCopy.js'
const router = Router() const router = Router()
@ -20,7 +19,7 @@ class PrinterStatusController {
static async status(req: Request, res: Response) { static async status(req: Request, res: Response) {
const { printerId } = req.params const { printerId } = req.params
const { take = 32, days = 60 } = req.query const { days = 60 } = req.query
const gte = new Date(Date.now() - 1000 * 60 * 60 * 24 * Number(days)) const gte = new Date(Date.now() - 1000 * 60 * 60 * 24 * Number(days))
@ -34,9 +33,7 @@ class PrinterStatusController {
orderBy: { timestamp: 'desc' } orderBy: { timestamp: 'desc' }
}) })
const distributedStatus = distributedCopy(status, Number(take)) res.json(status)
res.json(distributedStatus)
} }
} }