Skip to content

Commit

Permalink
Revert "Merge pull request #306 from RENCI/vg1"
Browse files Browse the repository at this point in the history
This reverts commit ed56620, reversing
changes made to d15371f.
  • Loading branch information
vladimir2217 committed Feb 17, 2023
1 parent f996403 commit 4e23a8b
Show file tree
Hide file tree
Showing 15 changed files with 2,705 additions and 174 deletions.
2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16
FROM node:13.14.0

RUN apt-get update && apt-get install -y nano tree tzdata

Expand Down
40 changes: 0 additions & 40 deletions api/controllers/ctsas.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const db = require('../config/database')
const {ParameterizedQuery: PQ} = require("pg-promise");

exports.list = (req, res) => {
const query = `SELECT * FROM "CTSAs";`
Expand All @@ -19,42 +18,3 @@ exports.list = (req, res) => {
})
}



exports.removeCTSA = (req, res) => {
const body = req.body
const ctsaId = body.ctsaId
const move1 = new PQ({
text: `INSERT into removeditems (created, tablename, item)
SELECT current_timestamp, 'CTSAs', to_jsonb(rows) FROM
(select * from "CTSAs" as ss where ss."ctsaId"=$1) rows;`,
values: [ctsaId]
})

const del1 = new PQ({
text: `DELETE from "CTSAs" as t where t."ctsaId" = $1;`,
values: [ctsaId]
})

let sites = 0

let q = db.any(new PQ({text: 'SELECT COUNT("ctsaId") FROM "Sites" where "ctsaId"=$1;', values:[body.ctsaId]}))
.then(data => sites = +data[0].count)
.then(d => {
if(sites < 1) {
db.any(move1)
.then(r=> db.any(del1)
.then(r => res.status(200).send('OK')))
}
else {
res.status(200).send('NOT REMOVED')
}
})
.catch(error => {
console.log('ERROR:', error)
res.status(500).send('There was an error fetching data.')
})

}


43 changes: 0 additions & 43 deletions api/controllers/sites.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const db = require('../config/database')
const {ParameterizedQuery: PQ} = require('pg-promise');

exports.list = (req, res) => {
const query = `SELECT * FROM "Sites";`
Expand All @@ -19,45 +18,3 @@ exports.list = (req, res) => {
res.status(500).send('There was an error fetching data.')
})
}

exports.removeSite = (req, res) => {
const body = req.body
let paramaters = [body.ctsaId, body.siteId, body.siteName];

const move1 = new PQ({
text: `INSERT into removeditems (created, tablename, item)
SELECT current_timestamp, 'StudySites', to_jsonb(rows) FROM
(select * from "StudySites" as ss where ss."ctsaId"=$1 and ss."siteId"=$2 and ss."siteName"=$3) rows;`,
values: paramaters
})

const move2 = new PQ({
text: `INSERT into removeditems (created, tablename, item)
SELECT current_timestamp, 'Sites', to_jsonb(rows) FROM
(select * from "Sites" as s where s."ctsaId"=$1 and s."siteId"=$2 and s."siteName"=$3) rows;`,
values: paramaters
})

const del1 = new PQ({
text: `DELETE from "StudySites" as ss where ss."ctsaId" = $1 and ss."siteId"=$2 and ss."siteName"=$3;`,
values: paramaters
})

const del2 = new PQ({
text: `DELETE from "Sites" as s where s."ctsaId" = $1 and s."siteId"=$2 and s."siteName"=$3;`,
values: paramaters
})

const r = db.any(move1)
.then(r => db.any(move2)
.then(r=> db.any(del1))
.then(r=> db.any(del2)
.then(r => res.status(200).send('OK'))))
.catch(error => {
console.log('ERROR:', error)
res.status(500).send('There was an error fetching data.')
})
Promise.all([r])
}


Loading

0 comments on commit 4e23a8b

Please sign in to comment.