From 3ed3bf3598c39a4fd037c12352806a181192a2ed Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Fri, 24 May 2019 13:31:55 +0300 Subject: [PATCH 1/6] remove redundant stuff --- scripts.sh | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/scripts.sh b/scripts.sh index f81e450b39..ce3c9f8454 100644 --- a/scripts.sh +++ b/scripts.sh @@ -91,21 +91,12 @@ db_oodikone_reset () { ping_psql () { echo "Pinging psql in container $1 with db name $2" retry docker exec -u postgres $1 pg_isready - docker exec -u postgres oodi_db psql -c "CREATE DATABASE tkt_oodi" || echo "tkt_oodi DB already exists" - echo "Pinging psql in container $1 with db name tkt_oodi_test" - retry docker exec -u postgres $1 pg_isready - docker exec -u postgres oodi_db psql -c "CREATE DATABASE tkt_oodi_test" || echo "tkt_oodi_test DB already exists" -} - -ping_psql_real () { - echo "Pinging psql in container $1 with db name $2" - docker exec -u postgres oodi_db psql -c "CREATE DATABASE tkt_oodi_real" || echo "tkt_oodi_real DB already exists" - retry docker exec -u postgres $1 pg_isready + docker exec -u postgres $1 psql -c "CREATE DATABASE $1" || echo "container $1 DB $2 already exists" } db_setup_full () { echo "Restoring PostgreSQL from backup" - ping_psql_real "oodi_db" "tkt_oodi_real" + ping_psql "oodi_db" "tkt_oodi_real" retry restore_real_psql_from_backup # echo "Restoring MongoDB from backup" # retry restore_mongodb_from_backup @@ -118,6 +109,7 @@ db_setup_full () { db_anon_setup_full () { echo "Restoring PostgreSQL from backup" ping_psql "oodi_db" "tkt_oodi" + ping_psql "oodi_db" "tkt_oodi_test" retry restore_psql_from_backup # echo "Restoring MongoDB from backup" # retry restore_mongodb_from_backup From d160a368bb6f71a409f983000fb7c472640d732e Mon Sep 17 00:00:00 2001 From: totutotu Date: Fri, 24 May 2019 13:47:07 +0300 Subject: [PATCH 2/6] Throughput to include transferred students --- .../src/services/studytrack.js | 52 ++++++++++++++++--- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/services/backend/oodikone2-backend/src/services/studytrack.js b/services/backend/oodikone2-backend/src/services/studytrack.js index 1266fdf672..4f24e205d6 100644 --- a/services/backend/oodikone2-backend/src/services/studytrack.js +++ b/services/backend/oodikone2-backend/src/services/studytrack.js @@ -270,11 +270,43 @@ const gendersFromClass = async (studentnumbers) => { }, {}) } -const productivityStats = async (studentnumbers, startDate, studytrack) => { +const tranferredToStudyprogram = async (studentnumbers, startDate, studytrack, endDate) => { + return Studyright.findAndCountAll({ + include: { + include: { + model: ElementDetails, + where: { + type: { + [Op.eq]: 20 + } + } + }, + model: StudyrightElement, + required: true, + where: { + code: { + [Op.eq]: studytrack + }, + startdate: { + [Op.gt]: moment(startDate).add(1, 'days'), // because somehow startdates have a time that is not 00:00 + [Op.lt]: new Date(endDate) + } + } + }, + where: { + student_studentnumber: { + [Op.in]: studentnumbers + } + } + }) +} + +const productivityStats = async (studentnumbers, startDate, studytrack, endDate) => { return Promise.all([creditsAfter(studentnumbers, startDate), - graduationsFromClass(studentnumbers, studytrack), - thesesFromClass(studentnumbers, startDate, studytrack), - gendersFromClass(studentnumbers)]) + graduationsFromClass(studentnumbers, studytrack), + thesesFromClass(studentnumbers, startDate, studytrack), + gendersFromClass(studentnumbers), + tranferredToStudyprogram(studentnumbers, startDate, studytrack, endDate)]) } const getYears = (since) => { @@ -298,14 +330,16 @@ const throughputStatsForStudytrack = async (studytrack, since) => { thesisM: 0, thesisB: 0, students: 0, - graduated: 0 + graduated: 0, + transferred: 0 } const years = getYears(since) const arr = await Promise.all(years.map(async year => { const startDate = `${year}-${semesterStart['FALL']}` const endDate = `${moment(year, 'YYYY').add(1, 'years').format('YYYY')}-${semesterEnd['SPRING']}` const studentnumbers = await studentnumbersWithAllStudyrightElements([studytrack], startDate, endDate, false, false) - const [credits, graduated, theses, genders] = await productivityStats(studentnumbers, startDate, studytrack) + const [credits, graduated, theses, genders, transferred] = + await productivityStats(studentnumbers, startDate, studytrack, endDate) delete genders[null] const creditValues = credits.reduce((acc, curr) => { acc.mte30 = curr >= 30 ? acc.mte30 + 1 : acc.mte30 @@ -326,7 +360,8 @@ const throughputStatsForStudytrack = async (studytrack, since) => { totals.thesisM = theses.MASTER ? totals.thesisM + theses.MASTER : totals.thesisM totals.thesisB = theses.BACHELOR ? totals.thesisB + theses.BACHELOR : totals.thesisB totals.students = totals.students + credits.length - totals.graduated = totals.graduated + graduated.length + totals.graduated = totals.graduated + graduated.length, + totals.transferred = totals.transferred + transferred.count return { year: `${year}-${year + 1}`, credits: credits.map(cr => cr === null ? 0 : cr), @@ -334,7 +369,8 @@ const throughputStatsForStudytrack = async (studytrack, since) => { thesisM: theses.MASTER || 0, thesisB: theses.BACHELOR || 0, genders, - creditValues + creditValues, + transferred: transferred.count } })) From 18bfed4773ac41122144e115037ba2827436a7dc Mon Sep 17 00:00:00 2001 From: totutotu Date: Fri, 24 May 2019 14:50:01 +0300 Subject: [PATCH 3/6] transferred students to throughput table --- .../src/components/StudyProgramme/ThroughputTable/index.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/oodikone2-frontend/src/components/StudyProgramme/ThroughputTable/index.jsx b/services/oodikone2-frontend/src/components/StudyProgramme/ThroughputTable/index.jsx index a761355371..5bfdee4dc6 100644 --- a/services/oodikone2-frontend/src/components/StudyProgramme/ThroughputTable/index.jsx +++ b/services/oodikone2-frontend/src/components/StudyProgramme/ThroughputTable/index.jsx @@ -66,6 +66,7 @@ const ThroughputTable = ({ history, throughput, thesis, loading, error, studypro Students } Graduated + Transferred to this program Credits {(thesisTypes.includes('BACHELOR') || thesisTypes.includes('MASTER')) && ( @@ -105,10 +106,11 @@ const ThroughputTable = ({ history, throughput, thesis, loading, error, studypro {year.credits.length} {genders.map(gender => ( - {`${year.genders[gender]} (${Math.floor((year.genders[gender] / year.credits.length) * 100)}%)` || 0} + {`${year.genders[gender] || 0} (${Math.floor((year.genders[gender] / year.credits.length) * 100) || 0}%)`} ))} {year.graduated} + {year.transferred} {Object.keys(year.creditValues).map(creditKey => ( {year.creditValues[creditKey]} @@ -133,6 +135,7 @@ const ThroughputTable = ({ history, throughput, thesis, loading, error, studypro ))} {throughput.totals.graduated} + {throughput.totals.transferred} {Object.keys(throughput.totals.credits).map(creditKey => ( {throughput.totals.credits[creditKey]} From f68fb5ff85ce166aea88749e82f5574416be311e Mon Sep 17 00:00:00 2001 From: esakemp Date: Mon, 27 May 2019 09:00:33 +0300 Subject: [PATCH 4/6] add user email to feedback --- services/backend/oodikone2-backend/src/routes/feedback.js | 7 ++++++- .../backend/oodikone2-backend/src/services/mailservice.js | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/services/backend/oodikone2-backend/src/routes/feedback.js b/services/backend/oodikone2-backend/src/routes/feedback.js index 2101808aa6..ba99805378 100644 --- a/services/backend/oodikone2-backend/src/routes/feedback.js +++ b/services/backend/oodikone2-backend/src/routes/feedback.js @@ -1,10 +1,15 @@ const router = require('express').Router() const mailservice = require('../services/mailservice') +const userService = require('../services/userService') router.post('/email', async (req, res) => { const { content } = req.body + const {uid} = req.headers + const { email } = await userService.byUsername(uid) + const formattedEmail = content.split('\n\n').map(line => `

${line}

`).join('') - const feedback = mailservice.feedback(formattedEmail, req.headers.uid) + const feedback = mailservice.feedback(formattedEmail, uid, email) + if (process.env.SMTP !== undefined && content) { await mailservice.transporter.sendMail(feedback, (error) => { if (error) { diff --git a/services/backend/oodikone2-backend/src/services/mailservice.js b/services/backend/oodikone2-backend/src/services/mailservice.js index 0a9de7f94f..f190d42a6b 100644 --- a/services/backend/oodikone2-backend/src/services/mailservice.js +++ b/services/backend/oodikone2-backend/src/services/mailservice.js @@ -62,13 +62,13 @@ const message2 = email => { `, }) } -const feedback = (content, user) => { +const feedback = (content, user, email) => { return ({ to: 'Toska ', subject: `New message from Oodikone feedback`, text: `New message from user ${user}`, html: `${content} -

send by user: ${user}

+

send by user: ${user}, email: ${email}

`, attachments: [ { From eded618adf37117a5f843e620ca6635c4543819d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4kinen=20Sasu=20S?= Date: Mon, 27 May 2019 12:32:34 +0300 Subject: [PATCH 5/6] fix known issue of 'oodikone-cli ei toimi' --- scripts.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.sh b/scripts.sh index ce3c9f8454..70a838f05d 100644 --- a/scripts.sh +++ b/scripts.sh @@ -91,7 +91,7 @@ db_oodikone_reset () { ping_psql () { echo "Pinging psql in container $1 with db name $2" retry docker exec -u postgres $1 pg_isready - docker exec -u postgres $1 psql -c "CREATE DATABASE $1" || echo "container $1 DB $2 already exists" + docker exec -u postgres $1 psql -c "CREATE DATABASE $2" || echo "container $1 DB $2 already exists" } db_setup_full () { From 4b3e907912c4683cd742cc4f58f6c0424009b7cc Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Mon, 27 May 2019 13:48:36 +0300 Subject: [PATCH 6/6] fix first time render of labels, disable save when label not changed --- .../components/StudyProgramme/MandatoryCourseTable/index.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/oodikone2-frontend/src/components/StudyProgramme/MandatoryCourseTable/index.jsx b/services/oodikone2-frontend/src/components/StudyProgramme/MandatoryCourseTable/index.jsx index 742f03e2de..638224625d 100644 --- a/services/oodikone2-frontend/src/components/StudyProgramme/MandatoryCourseTable/index.jsx +++ b/services/oodikone2-frontend/src/components/StudyProgramme/MandatoryCourseTable/index.jsx @@ -21,8 +21,9 @@ const MandatoryCourseTable = ({ studyProgramme, mandatoryCourses, language, dele const labelInput = code => (
- setLabels({ ...labels, [code]: e.target.value })} /> + setLabels({ ...labels, [code]: e.target.value })} /> setMandatoryCourseLabel(studyProgramme, code, labels[code])} > Save label