import pg from "../postgres.js";
// Imports
import {
  insertQuery,
  selectWhereAnyQuery,
  updateWhereAnyQuery,
} from "../pg-query.js";
// Constants
const table = "test_results";
// Queries
export const insertTestResult = (testResult) => {
  const {
    test_name,
    test_class,
    test_method,
    test_path,
    test_type,
    test_timestamp,
    test_retry,
    origin,
    failed,
    failed_message,
    screenshot_url,
    expected_screenshot_url,
    weblog_url,
  } = testResult;

  var query = insertQuery(table, {
    test_name,
    test_class,
    test_method,
    test_path,
    test_type,
    test_timestamp,
    test_retry,
    origin,
    failed,
    failed_message,
    screenshot_url,
    expected_screenshot_url,
    weblog_url,
  });

  query += "\n RETURNING *";
  return pg.query(query);
};

export const getCurrentlyFailing = () => {
  const query = "SELECT *";
  return pg.query(query);
};
