mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 08:47:07 +00:00
Auto-refresh materialised view if necessary
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const { setSurvey } = require('../../connection');
|
||||
const refresh = require('./refresh');
|
||||
|
||||
async function get (projectId, opts = {}) {
|
||||
try {
|
||||
@@ -13,7 +14,11 @@ async function get (projectId, opts = {}) {
|
||||
client.release();
|
||||
return res.rows[0];
|
||||
} catch (err) {
|
||||
if (err.code == "42P01") {
|
||||
if (err.code == "55000") {
|
||||
// Materialised view has not been refreshed
|
||||
await refresh(projectId, opts);
|
||||
return get(projectId, opts);
|
||||
} else if (err.code == "42P01") {
|
||||
throw { status: 404, message: "Not found" };
|
||||
} else {
|
||||
throw err;
|
||||
|
||||
Reference in New Issue
Block a user