Skip to content

Commit

Permalink
Update for 2023 budget proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Mar 24, 2023
1 parent 05335bf commit 6bd21be
Show file tree
Hide file tree
Showing 9 changed files with 18,530 additions and 7,471 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
with:
node-version: '10'
node-version: '16'
- name: Build
env:
TRAVIS_CI_OPERATOR: "1"
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
@@ -1,10 +1,10 @@
FROM node:8-alpine
FROM node:14-slim

RUN apk add --update git
# RUN apt-get add --update git

COPY . /app/
RUN cd /app/ && \
npm install --no-audit && \
npm install --no-audit --legacy-peer-deps && \
npm run build --prod

EXPOSE 8000
Expand Down
22 changes: 19 additions & 3 deletions cache.js
Expand Up @@ -8,6 +8,7 @@ const _ = require('lodash');
const API_URL = 'https://next.obudget.org/api/query?query=';
const DOC_URL = 'https://next.obudget.org/get/';
const YEAR = 2022;
const PROPOSAL_YEAR = 2023;
const BUDGET_CODE = '0020670142';

const RETURNS_CONDITION = `
Expand All @@ -23,11 +24,13 @@ const GOV_INDUSTIES_CONDITION = `
code LIKE '0098%%')
`;

const EXPENSES_CONDITION = `length(code) = 10 AND year = ` + YEAR + `
const TOTAL_BUDGET_CONDITION = `
AND NOT code LIKE '0000%%'
AND NOT ` + GOV_INDUSTIES_CONDITION + `
AND NOT ` + RETURNS_CONDITION;

const EXPENSES_CONDITION = `length(code) = 10 AND year = ` + YEAR + TOTAL_BUDGET_CONDITION;

const DEFICIT_FUNDING_CONDITION = `
((func_cls_json->>0)::jsonb->>2='86')
`;
Expand All @@ -36,6 +39,15 @@ const INCOME_CONDITION = `length(code) = 10 AND year = ` + (YEAR - 1) + `
AND code LIKE '0000%%'
AND NOT ` + DEFICIT_FUNDING_CONDITION;

const SQL_TOTAL_PROPOSAL_DATA = `
SELECT sum(net_allocated) AS total_amount
FROM raw_budget
WHERE length(code) = 8 and year = ` + PROPOSAL_YEAR + TOTAL_BUDGET_CONDITION;
const SQL_TOTAL_PREV_PROPOSAL_DATA = `
SELECT sum(net_allocated) AS total_amount
FROM raw_budget
WHERE length(code) = 8 and year = ` + (PROPOSAL_YEAR-1) + TOTAL_BUDGET_CONDITION;

const SQL_FUNC_BUBBLES_DATA = `
SELECT
func_cls_title_1->>0 || ':budget/C' || ((func_cls_json->>0)::json->>0) || '/' || '` + YEAR + `' AS bubble_group,
Expand Down Expand Up @@ -296,7 +308,9 @@ function get_cache() {
fetch_data(SQL_INCOME_BUBBLES_DATA),
deficitChart(),
educationBudgetChart(),
supportsChart()
supportsChart(),
fetch_sql(SQL_TOTAL_PROPOSAL_DATA),
fetch_sql(SQL_TOTAL_PREV_PROPOSAL_DATA),
]).then((data) => {
ret = {
year: YEAR,
Expand All @@ -305,7 +319,9 @@ function get_cache() {
income: data[2],
deficitChart: data[3],
educationCharts: data[4],
supportChart: data[5]
supportChart: data[5],
proposalAmount: data[6],
prevProposalAmount: data[7],
};
return fetchExplanations(data[0]);
}).then((exp) => {
Expand Down

0 comments on commit 6bd21be

Please sign in to comment.