mirror of
https://github.com/UniversityOfHelsinkiCS/oodikone.git
synced 2026-10-12 19:03:39 +03:00
initial commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
.vscode
|
||||||
Generated
+3887
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "nodetest",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^0.16.2",
|
||||||
|
"install": "^0.10.1",
|
||||||
|
"knex": "^0.13.0",
|
||||||
|
"moment": "^2.19.1",
|
||||||
|
"npm": "^5.4.2",
|
||||||
|
"pg": "^7.3.0",
|
||||||
|
"pg-hstore": "^2.3.2",
|
||||||
|
"sequelize": "^4.13.8"
|
||||||
|
}
|
||||||
|
}
|
||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
const Sequelize = require('sequelize')
|
||||||
|
const moment = require('moment')
|
||||||
|
const { Student, Credit, Studyright, sequelize } = require('./models')
|
||||||
|
const Op = Sequelize.Op;
|
||||||
|
|
||||||
|
const studyrightsStartedAt = (date) => {
|
||||||
|
return Studyright.findAll({
|
||||||
|
limit : 200,
|
||||||
|
include: [ {
|
||||||
|
model: Student,
|
||||||
|
include: [ Credit ]
|
||||||
|
} ],
|
||||||
|
where: {
|
||||||
|
startdate: {
|
||||||
|
[Op.eq]: new Date(date)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const studentsStartedAtDepartment = (studyrights, dep, startDate) => {
|
||||||
|
const hasNoPreviousStudies = (s) => {
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasStarted = (s) => {
|
||||||
|
return s.credits.length>0
|
||||||
|
}
|
||||||
|
|
||||||
|
return studyrights
|
||||||
|
.filter( s => s.highlevelname === dep )
|
||||||
|
.map( s => s.student )
|
||||||
|
.filter( hasStarted )
|
||||||
|
.filter( hasNoPreviousStudies )
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
try {
|
||||||
|
const BSC_CS = 'Bachelor of Science, Computer Science'
|
||||||
|
const BSC_MATH = 'Bachelor of Science, Mathematics'
|
||||||
|
|
||||||
|
const startDate = '2005-08-01'
|
||||||
|
|
||||||
|
const studyrights = await studyrightsStartedAt(startDate)
|
||||||
|
|
||||||
|
const cs = studentsStartedAtDepartment(studyrights, BSC_CS, moment(startDate))
|
||||||
|
|
||||||
|
cs.forEach( s => console.log(s.studentnumber))
|
||||||
|
|
||||||
|
//console.log(studyrights.map(s=>s.student.studentnumber))
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
sequelize.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
const Sequelize = require('sequelize')
|
||||||
|
|
||||||
|
const sequelize = new Sequelize('tkt_oodi', 'tkt_oodi', process.ENV.PW, {
|
||||||
|
host: 'localhost',
|
||||||
|
dialect:'postgres',
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const Student = sequelize.define('student',
|
||||||
|
{
|
||||||
|
studentnumber: {
|
||||||
|
primaryKey: true,
|
||||||
|
type: Sequelize.STRING
|
||||||
|
},
|
||||||
|
lastname: { type: Sequelize.STRING },
|
||||||
|
firstnames: { type: Sequelize.STRING },
|
||||||
|
abbreviatedname: { type: Sequelize.STRING },
|
||||||
|
birthdate: { type: Sequelize.DATE },
|
||||||
|
communicationlanguage: { type: Sequelize.STRING },
|
||||||
|
country: { type: Sequelize.STRING },
|
||||||
|
creditcount: { type: Sequelize.INTEGER },
|
||||||
|
dateoffirstcredit: { type: Sequelize.DATE },
|
||||||
|
dateoflastcredit: { type: Sequelize.DATE },
|
||||||
|
dateofuniversityenrollment: { type: Sequelize.DATE },
|
||||||
|
gradestudent: { type: Sequelize.STRING },
|
||||||
|
matriculationexamination: { type: Sequelize.STRING },
|
||||||
|
nationalities: { type: Sequelize.STRING },
|
||||||
|
semesterenrollmenttypecode: { type: Sequelize.STRING },
|
||||||
|
sex: { type: Sequelize.STRING },
|
||||||
|
studentstatuscode: { type: Sequelize.INTEGER },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tableName: 'student',
|
||||||
|
timestamps: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const Credit = sequelize.define('credit',
|
||||||
|
{
|
||||||
|
id: {
|
||||||
|
primaryKey: true,
|
||||||
|
type: Sequelize.STRING
|
||||||
|
},
|
||||||
|
grade: { type: Sequelize.STRING },
|
||||||
|
student_studentnumber: { type: Sequelize.STRING },
|
||||||
|
credits: { type: Sequelize.DOUBLE },
|
||||||
|
ordering: { type: Sequelize.STRING },
|
||||||
|
status: { type: Sequelize.STRING },
|
||||||
|
statuscode: { type: Sequelize.STRING },
|
||||||
|
courseinstance_id: { type: Sequelize.BIGINT },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tableName: 'credit',
|
||||||
|
timestamps: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const Studyright = sequelize.define('studyright',
|
||||||
|
{
|
||||||
|
studyrightid: {
|
||||||
|
primaryKey: true,
|
||||||
|
type: Sequelize.BIGINT
|
||||||
|
},
|
||||||
|
canceldate: { type: Sequelize.DATE },
|
||||||
|
cancelorganisation: { type: Sequelize.STRING },
|
||||||
|
enddate: { type: Sequelize.DATE },
|
||||||
|
extentcode: { type: Sequelize.INTEGER },
|
||||||
|
givendate: { type: Sequelize.DATE },
|
||||||
|
graduated: { type: Sequelize.INTEGER },
|
||||||
|
highlevelname: { type: Sequelize.STRING },
|
||||||
|
prioritycode: { type: Sequelize.INTEGER },
|
||||||
|
startdate: { type: Sequelize.DATE },
|
||||||
|
studystartdate: { type: Sequelize.DATE },
|
||||||
|
organization_code: { type: Sequelize.STRING },
|
||||||
|
student_studentnumber: { type: Sequelize.STRING },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tableName: 'studyright',
|
||||||
|
timestamps: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
Credit.belongsTo(Student, {foreignKey: 'student_studentnumber', targetKey: 'studentnumber'});
|
||||||
|
Student.hasMany(Credit, {foreignKey: 'student_studentnumber', sourceKey: 'studentnumber'});
|
||||||
|
|
||||||
|
Studyright.belongsTo(Student, {foreignKey: 'student_studentnumber', targetKey: 'studentnumber'});
|
||||||
|
Student.hasMany(Studyright, {foreignKey: 'student_studentnumber', sourceKey: 'studentnumber'});
|
||||||
|
|
||||||
|
module.exports = {Student, Credit, Studyright, sequelize}
|
||||||
Reference in New Issue
Block a user