mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:47:08 +00:00
Add a refresh() method to db.project.summary
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
module.exports = {
|
||||
get: require('./get'),
|
||||
refresh: require('./refresh')
|
||||
};
|
||||
|
||||
23
lib/www/server/lib/db/project/summary/refresh.js
Normal file
23
lib/www/server/lib/db/project/summary/refresh.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const { setSurvey } = require('../../connection');
|
||||
|
||||
async function refresh (projectId, opts = {}) {
|
||||
try {
|
||||
const client = await setSurvey(projectId);
|
||||
|
||||
const text = `
|
||||
REFRESH MATERIALIZED VIEW project_summary;
|
||||
`;
|
||||
|
||||
const res = await client.query(text);
|
||||
client.release();
|
||||
return res.rows[0];
|
||||
} catch (err) {
|
||||
if (err.code == "42P01") {
|
||||
throw { status: 404, message: "Not found" };
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = refresh;
|
||||
Reference in New Issue
Block a user