Skip to content

Commit

Permalink
Merge pull request #1809 from UniversityOfHelsinkiCS/trunk
Browse files Browse the repository at this point in the history
Add connection pool size env var to backend, populations view tab style fixes, code style improvements
  • Loading branch information
cxcorp authored Jan 9, 2020
2 parents de4946b + a57ec0d commit a829afb
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 27 deletions.
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,14 @@ services:
environment:
REDIS: redis
DB_URL: postgres://postgres@db:5432/tkt_oodi
# DB_MAX_CONNECTIONS: 90 # defaults to 5
DB_URL_KONE: postgres://postgres@db_kone:5432/db_kone
# if NODE_ENV === 'test', these are used instead
TEST_DB: postgres://postgres@db:5432/tkt_oodi_test
TEST_DB_KONE: postgres://postgres@db_kone:5432/db_kone_test
# same but for NODE_ENV === 'anon'
# ANON_DB:
# ANON_DB_KONE:
TOKEN_SECRET: IWannaBeTheVeryBest
USERSERVICE_URL: http://userservice:4567
USAGESERVICE_URL: http://usageservice:545
Expand Down
7 changes: 7 additions & 0 deletions services/backend/oodikone2-backend/src/conf-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ if (isTest) {
DB_URL = process.env.ANON_DB
DB_URL_KONE = process.env.ANON_DB_KONE
}

let DB_MAX_CONNECTIONS = parseInt(process.env.DB_MAX_CONNECTIONS, 10)
if (isNaN(DB_MAX_CONNECTIONS)) {
DB_MAX_CONNECTIONS = 5 // sequelize's default
}

const frontend_addr = process.env.FRONT_URL
const redis = process.env.REDIS
const TOKEN_SECRET = process.env.TOKEN_SECRET
Expand Down Expand Up @@ -73,6 +79,7 @@ module.exports = {
frontend_addr,
DB_URL,
DB_URL_KONE,
DB_MAX_CONNECTIONS,
redis,
TOKEN_SECRET,
DB_SCHEMA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ const conf = require('../conf-backend')
const sequelize = new Sequelize(conf.DB_URL, {
schema: conf.DB_SCHEMA,
searchPath: conf.DB_SCHEMA,
logging: false
logging: false,
pool: {
min: 0,
max: conf.DB_MAX_CONNECTIONS
}
})
sequelize.query(`SET SESSION search_path to ${conf.DB_SCHEMA}`)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,23 +549,23 @@ class PopulationStudents extends Component {
</React.Fragment>
)}
</div>
<div
style={{
paddingLeft: '10px',
minHeight: '300px',
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
}}
>
{this.props.mandatoryCourses.length === 0 && (
{this.props.mandatoryCourses.length === 0 && (
<div
style={{
paddingLeft: '10px',
minHeight: '300px',
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
}}
>
<h3>
No mandatory courses defined. You can define them{' '}
<Link to={`/study-programme/${this.props.queryStudyrights[0]}?p_m_tab=0&p_tab=1`}>here</Link>.
</h3>
)}
</div>
</div>
)}
</div>
</Tab.Pane>
)
Expand All @@ -575,23 +575,23 @@ class PopulationStudents extends Component {
render: () => (
<Tab.Pane>
<div style={{ overflowX: 'auto', maxHeight: '80vh' }}>
<div
style={{
paddingLeft: '10px',
minHeight: '300px',
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
}}
>
{this.props.tags.length === 0 && (
{this.props.tags.length === 0 && (
<div
style={{
paddingLeft: '10px',
minHeight: '300px',
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
}}
>
<h3>
No tags defined. You can define them{' '}
<Link to={`/study-programme/${this.props.queryStudyrights[0]}?p_m_tab=0&p_tab=5`}>here</Link>.
</h3>
)}
</div>
</div>
)}
{this.props.tags.length > 0 && (
<React.Fragment>
<TagPopulation
Expand Down

0 comments on commit a829afb

Please sign in to comment.