const HistoryValue = require('../services/history_value.service');
const { setResponsePaging } = require('../helpers/utils');

class HistoryValueController {

  static async getAllHistoryAlarm(req, res) {
    const queryParams = req.query;

    const results = await HistoryValue.getAllHistoryAlarm(queryParams);
    const response = await setResponsePaging(queryParams, results, 'Data found');

    res.status(response.statusCode).json(response);
  }

  static async getAllHistoryEvent(req, res) {
    const queryParams = req.query;

    const results = await HistoryValue.getAllHistoryEvent(queryParams);
    const response = await setResponsePaging(queryParams, results, 'Data found');

    res.status(response.statusCode).json(response);
  }

  static async getHistoryValueReport(req, res) {
    const queryParams = req.query;

    const results = await HistoryValue.getHistoryValueReport(queryParams);
    const response = await setResponsePaging(queryParams, results, 'Data found');

    res.status(response.statusCode).json(response);
  }

  static async getHistoryValueReportPivot(req, res) {
    const queryParams = req.query;

    const results = await HistoryValue.getHistoryValueReportPivot(queryParams);
    const response = await setResponsePaging(queryParams, results, 'Data found');

    response.columns = results.column

    res.status(response.statusCode).json(response);
  }

  static async getHistoryValueTrendingPivot(req, res) {
    const queryParams = req.query;

    const results = await HistoryValue.getHistoryValueTrendingPivot(queryParams);
    const response = await setResponsePaging(queryParams, results, 'Data found');

    response.columns = results.column

    res.status(response.statusCode).json(response);
  }
}

module.exports = HistoryValueController;
