|
@@ -311,12 +311,19 @@ function createPgStore({ connectionString, ssl = true, max = 5, schema = 'public
|
|
|
|
|
|
|
|
async function summary() {
|
|
async function summary() {
|
|
|
const poolRef = getPool();
|
|
const poolRef = getPool();
|
|
|
- const [uploadCount, rowCount, platformRowCount, range, schools, shops, last] = await Promise.all([
|
|
|
|
|
|
|
+ const [uploadCount, rowCount, platformRowCount, range, matrix, schools, shops, last] = await Promise.all([
|
|
|
poolRef.query('SELECT COUNT(*)::int AS c FROM ops_upload'),
|
|
poolRef.query('SELECT COUNT(*)::int AS c FROM ops_upload'),
|
|
|
poolRef.query('SELECT COUNT(*)::int AS c FROM ops_row'),
|
|
poolRef.query('SELECT COUNT(*)::int AS c FROM ops_row'),
|
|
|
poolRef.query('SELECT COUNT(*)::int AS c FROM ops_platform_row'),
|
|
poolRef.query('SELECT COUNT(*)::int AS c FROM ops_platform_row'),
|
|
|
- poolRef.query('SELECT MIN(date) AS f, MAX(date) AS t FROM ops_row'),
|
|
|
|
|
- poolRef.query('SELECT school, COUNT(*)::int AS c FROM ops_shop GROUP BY school ORDER BY school ASC'),
|
|
|
|
|
|
|
+ poolRef.query(`SELECT MIN(d) AS f, MAX(d) AS t FROM (
|
|
|
|
|
+ SELECT date AS d FROM ops_row UNION SELECT date AS d FROM ops_platform_row)`),
|
|
|
|
|
+ poolRef.query(`SELECT COUNT(*)::int AS c FROM (
|
|
|
|
|
+ SELECT date, shop_key FROM ops_row UNION SELECT date, shop_id FROM ops_platform_row)`),
|
|
|
|
|
+ poolRef.query(`SELECT school, COUNT(DISTINCT shop)::int AS c FROM (
|
|
|
|
|
+ SELECT school, shop_id AS shop FROM ops_platform_row WHERE school <> ''
|
|
|
|
|
+ UNION SELECT school, shop_key AS shop FROM ops_row WHERE school <> ''
|
|
|
|
|
+ UNION SELECT school, key AS shop FROM ops_shop WHERE school <> ''
|
|
|
|
|
+ ) AS t GROUP BY school ORDER BY school ASC`),
|
|
|
poolRef.query('SELECT key, shop_id, shop_name, school, status FROM ops_shop ORDER BY school ASC, shop_name ASC'),
|
|
poolRef.query('SELECT key, shop_id, shop_name, school, status FROM ops_shop ORDER BY school ASC, shop_name ASC'),
|
|
|
poolRef.query('SELECT id, original_name, uploaded_at, report FROM ops_upload ORDER BY uploaded_at DESC LIMIT 1'),
|
|
poolRef.query('SELECT id, original_name, uploaded_at, report FROM ops_upload ORDER BY uploaded_at DESC LIMIT 1'),
|
|
|
]);
|
|
]);
|
|
@@ -326,6 +333,7 @@ function createPgStore({ connectionString, ssl = true, max = 5, schema = 'public
|
|
|
uploadCount: uploadCount.rows[0].c,
|
|
uploadCount: uploadCount.rows[0].c,
|
|
|
rowCount: rowCount.rows[0].c,
|
|
rowCount: rowCount.rows[0].c,
|
|
|
platformRowCount: platformRowCount.rows[0].c,
|
|
platformRowCount: platformRowCount.rows[0].c,
|
|
|
|
|
+ matrixRowCount: matrix.rows[0].c,
|
|
|
coverage: range.rows[0] && range.rows[0].f ? { from: String(range.rows[0].f).replace(/-/g, ''), to: String(range.rows[0].t).replace(/-/g, '') } : null,
|
|
coverage: range.rows[0] && range.rows[0].f ? { from: String(range.rows[0].f).replace(/-/g, ''), to: String(range.rows[0].t).replace(/-/g, '') } : null,
|
|
|
lastUpload: last.rows.length ? {
|
|
lastUpload: last.rows.length ? {
|
|
|
id: last.rows[0].id,
|
|
id: last.rows[0].id,
|