Skip to content

Commit

Permalink
Merge pull request #1045 from UniversityOfHelsinkiCS/trunk
Browse files Browse the repository at this point in the history
get rid of old staging
  • Loading branch information
esakemp authored Jun 20, 2019
2 parents 0448d0b + 81259ef commit 6ceca87
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 77 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
- docker ps
- cat nginx/log
- docker-compose logs -f &
- until $(curl --output /dev/null --silent --fail http://localhost:1337/staging/); do printf '.'; sleep 5; done
- until $(curl --output /dev/null --silent --fail http://localhost:1337/); do printf '.'; sleep 5; done
- time npm run test_services
- time CYPRESS_baseUrl=http://localhost:1337/staging/ npm run cypress:record
- time CYPRESS_baseUrl=http://localhost:1337/ npm run cypress:record
- docker ps -a
- if [[ $(docker ps --all | grep -Eo '(Exited|Restarting) \([0-9]+\)' | grep -Eo '[0-9]+' | awk '{ sum += $1 } END { print sum }') != '0' ]]; then echo 'Some process had nonzero exit code'; exit 1; fi
deploy: # deploy is always skipped for PR
Expand Down
19 changes: 3 additions & 16 deletions docker-compose.lateste2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ services:
REDIS: redis
DB_URL: postgres://postgres@db:5432/tkt_oodi
TEST_DB: postgres://postgres@db:5432/tkt_oodi_test
FRONT_URL: http://localhost:1337/staging
FRONT_URL: http://localhost:1337
TOKEN_SECRET: IWannaBeTheVeryBest
OODILEARN_URL: http://oodilearn:5000
USERSERVICE_URL: http://userservice:4567
Expand All @@ -97,28 +97,15 @@ services:
build:
context: services/oodikone2-frontend
args:
BASE_PATH: /staging/
BASE_PATH: /
ports:
- "5000:5000"
environment:
WAIT_HOSTS: user_db:5432
BACKEND_ADDR: backend
ADMINER_URL: http://localhost:5050/?pgsql=db&username=postgres
container_name: frontend
newfrontend:
image: toska/oodikone2-frontend:newstaging
build:
context: services/oodikone2-frontend
args:
BASE_PATH: /
ports:
- "5001:5001"
environment:
WAIT_HOSTS: user_db:5432
BACKEND_ADDR: backend
ADMINER_URL: http://localhost:5050/?pgsql=db&username=postgres
container_name: newfrontend


userservice:
image: toska/oodikone2-userservice:staging
build:
Expand Down
4 changes: 2 additions & 2 deletions nginx.staging.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ http {
server {
listen 80;

location /staging/ {
location / {
proxy_pass http://frontend:5000/;
}

location /staging/api/ {
location /api/ {
proxy_pass http://backend:8080/;
}
}
Expand Down
4 changes: 1 addition & 3 deletions services/oodikone2-frontend/src/apiConnection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ export const handleRequest = store => next => async (action) => {
}

export const logout = async () => {
const stagingPath = '/staging'
const returnUrl = window.location.pathname.includes(stagingPath) ?
`${window.location.origin}${stagingPath}` : window.location.origin
const returnUrl = window.location.origin
const response = await getAxios().delete('/logout', { data: { returnUrl } })
localStorage.removeItem(TOKEN_NAME)
window.location = response.data.logoutUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const getHeader = (categoryName) => {
}

const CumulativeTable = ({ categoryName, data, onClickCourse }) => (
<Table>
<Table style={{ cursor: 'pointer' }} selectable>
{getHeader(categoryName)}
<Table.Body>
{ data.map(course =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class TeacherLeaderBoard extends Component {

<TeacherStatisticsTable
statistics={statistics}
onClickFn={e => this.props.history.push(`/teachers/${e.target.innerText}`)}
onClickFn={id => this.props.history.push(`/teachers/${id}`)}
/>
</Segment>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ class TeacherStatistics extends Component {
<Segment>
<TeacherStatisticsTable
statistics={statistics}
onClickFn={e =>
this.props.history.push(`/teachers/${e.target.innerText}`)
onClickFn={id =>
this.props.history.push(`/teachers/${id}`)
}
/>
</Segment>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,52 @@
import React, { Component } from 'react'
import { Table, Segment } from 'semantic-ui-react'
import { shape, arrayOf, any, string, number } from 'prop-types'
import { shape, arrayOf, any, string, number, func } from 'prop-types'
import _ from 'lodash'

const calculatePassrate = (pass, fail) => (100 * pass) / (pass + fail)

class TeacherStatisticsTable extends Component {
state={
selected: 'credits',
direction: 'descending'
}
state = {
selected: 'credits',
direction: 'descending'
}

handleSort = column => () => {
const { selected, direction } = this.state
if (selected === column) {
this.setState({
direction: direction === 'ascending' ? 'descending' : 'ascending'
})
} else {
this.setState({
selected: column,
direction: 'descending'
})
}
handleSort = column => () => {
const { selected, direction } = this.state
if (selected === column) {
this.setState({
direction: direction === 'ascending' ? 'descending' : 'ascending'
})
} else {
this.setState({
selected: column,
direction: 'descending'
})
}
}

sortStatistics = (statistics) => {
const { selected, direction } = this.state
const formatted = statistics.map(stat => ({
...stat,
passrate: calculatePassrate(stat.passed, stat.failed)
}))
const sorted = _.sortBy(formatted, selected)
return direction === 'ascending' ? sorted : sorted.reverse()
}
sortStatistics = (statistics) => {
const { selected, direction } = this.state
const formatted = statistics.map(stat => ({
...stat,
passrate: calculatePassrate(stat.passed, stat.failed)
}))
const sorted = _.sortBy(formatted, selected)
return direction === 'ascending' ? sorted : sorted.reverse()
}

render() {
const { statistics } = this.props
const { selected, direction } = this.state
render() {
const { statistics, onClickFn } = this.props
const { selected, direction } = this.state

const sortDirection = name => (selected === name ? direction : null)
const sortDirection = name => (selected === name ? direction : null)

return (statistics.length === 0 ? <Segment basic content="No statistics found for the given query." /> :
<Table structured celled textAlign="center" sortable>
return (statistics.length === 0 ?
<Segment basic content="No statistics found for the given query." />
:
<Table structured celled textAlign="center" sortable selectable>
<Table.Header>
<Table.Row>
<Table.HeaderCell
content="ID"
onClick={this.handleSort('id')}
sorted={sortDirection('id')}
/>
<Table.HeaderCell
content="Name"
textAlign="left"
Expand All @@ -74,21 +71,19 @@ class TeacherStatisticsTable extends Component {
</Table.Row>
</Table.Header>
<Table.Body>
{ this.sortStatistics(statistics).map(({ id, name, credits, passrate, transferred }) => (
<Table.Row key={id}>
<Table.Cell content={id} width={1} onClick={this.props.onClickFn} /> {/* eslint-disable-line*/}
{this.sortStatistics(statistics).map(({ id, name, credits, passrate, transferred }) => (
<Table.Row key={id} onClick={() => onClickFn(id)} style={{ cursor: 'pointer' }} >
<Table.Cell content={name} textAlign="left" />
<Table.Cell content={credits} width={2} />
<Table.Cell content={transferred} width={2} />
<Table.Cell content={`${parseFloat(passrate).toFixed(2)} %`} width={2} />
</Table.Row>
))}
))}
</Table.Body>
</Table>
)
}
)
}
}

TeacherStatisticsTable.propTypes = {
statistics: arrayOf(shape({
id: any,
Expand All @@ -97,7 +92,9 @@ TeacherStatisticsTable.propTypes = {
credits: any,
failed: number,
passed: number
})).isRequired
})).isRequired,
onClickFn: func.isRequired
}


export default TeacherStatisticsTable
4 changes: 2 additions & 2 deletions services/oodikone2-frontend/src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const hiddenRoutes = {
}

const assumeBasename = () => {
const POSSIBLE_BASENAMES = ['staging', 'testing']
const POSSIBLE_BASENAMES = ['testing']
const haystack = window.location.pathname.split('/')
const needle = haystack.find(path => POSSIBLE_BASENAMES.includes(path))
return needle ? `/${needle}/` : '/'
Expand All @@ -86,7 +86,7 @@ export const DEFAULT_LANG = 'en'
export const DISPLAY_DATE_FORMAT = 'DD.MM.YYYY'
export const API_DATE_FORMAT = 'YYYY.MM.DD'

export const TOKEN_NAME = window.location.pathname.includes('/staging') ? 'staging_token' : window.location.pathname.includes('/testing') ? 'testing_token' : 'token' //eslint-disable-line
export const TOKEN_NAME = window.location.pathname.includes('staging') ? 'staging_token' : window.location.pathname.includes('/testing') ? 'testing_token' : 'token' //eslint-disable-line

export const passRateCumGraphOptions = (categories, max) => ({
chart: {
Expand Down
5 changes: 2 additions & 3 deletions services/oodikone2-frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ module.exports = (env, args) => {
port: devServerPort,
proxy: [
{
context: ['/api', '/staging/api'],
target: backendURL,
pathRewrite: { '^/staging': '' }
context: ['/api'],
target: backendURL
}
]
}
Expand Down

0 comments on commit 6ceca87

Please sign in to comment.