Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mluukkai committed Feb 1, 2024
1 parent 928170f commit fdb09e9
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
6 changes: 3 additions & 3 deletions cypress/integration/reclaimer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const runSharedTests = () => {
cy.get('[data-cy=reclaimerContent]').should('not.contain', 'fuksiEtunimi')
})

it('Doesn\'t show student who is present with more than 30 credits first year and device newer than five years', () => {
it('Doesn\'t show student who is present with more than 20 credits first year and device newer than five years', () => {
cy.get('[data-cy=reclaimerContent]').should('not.contain', 'Oppilas Mallikas')
})

Expand Down Expand Up @@ -101,11 +101,11 @@ context('Reclaimer View', () => {
cy.get('[data-cy=reclaimerContent]').should('not.contain', 'Laite Vanhatar')
})

it('Shows device holder with under 30 credits first study year', () => {
it('Shows device holder with under 20 credits first study year', () => {
cy.get('[data-cy=reclaimerContent]').contains('Haltija Pisteetön')
})

it('Doesn\'t show third+ year student with under 30 credits on first study year', () => {
it('Doesn\'t show third+ year student with under 20 credits on first study year', () => {
cy.get('[data-cy=reclaimerContent]').should('not.contain', 'Senior Opiskelija')
})

Expand Down
2 changes: 0 additions & 2 deletions server/middleware/authenticationMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ const authentication = async (req, res, next) => {
return res.sendStatus(403)
}

console.log('hygroupcn', hygroupcn)
console.log('username', uid)
req.toska = hygroupcn && hygroupcn.includes('grp-toska')

const foundUser = await User.findOne({
Expand Down
36 changes: 28 additions & 8 deletions server/models/lib/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ const mockData = {
{
code: 'KH50_005',
start_date: '2020-07-31T21:00:00.000Z',
end_date: '2025-07-30T21:00:00.000Z',
end_date: '2026-07-30T21:00:00.000Z',
},
],
admission_date: '2017-06-30T21:00:00.000Z',
end_date: '2024-07-30T21:00:00.000Z',
end_date: '2026-07-30T21:00:00.000Z',
start_date: '2017-07-31T21:00:00.000Z',
valid: {
end_date: '2026-07-30T21:00:00.000Z',
start_date: '2017-07-31T21:00:00.000Z',
},
id: 'hy-opinoik-131106475',
},
],
Expand Down Expand Up @@ -405,7 +409,7 @@ const mockData = {
],
},
},
firstYearCredits: 29,
firstYearCredits: 19,
},
exDeviceHolder: {
semesterEnrollments: {
Expand All @@ -424,7 +428,7 @@ const mockData = {
],
},
},
firstYearCredits: 29,
firstYearCredits: 19,
},
eligible2: {
studyrights: {
Expand All @@ -442,6 +446,10 @@ const mockData = {
end_date: '2024-07-30T21:00:00.000Z',
start_date: '2017-07-31T21:00:00.000Z',
id: 'hy-opinoik-131106475',
valid: {
end_date: '2024-07-30T21:00:00.000Z',
start_date: '2017-07-31T21:00:00.000Z',
},
},
],
},
Expand Down Expand Up @@ -489,8 +497,10 @@ const mockData = {
},
],
admission_date: '2017-06-30T21:00:00.000Z',
end_date: '2024-07-30T21:00:00.000Z',
start_date: '2017-07-31T21:00:00.000Z',
valid: {
start_date: '2008-07-31T21:00:00.000Z',
end_date: '2040-07-30T21:00:00.000Z',
},
id: 'hy-opinoik-131106475',
},
],
Expand Down Expand Up @@ -533,9 +543,11 @@ const mockData = {
},
],
admission_date: '2017-06-30T21:00:00.000Z',
end_date: '2024-07-30T21:00:00.000Z',
start_date: '2017-07-31T21:00:00.000Z',
id: 'hy-opinoik-131106475',
valid: {
start_date: '2005-07-31T21:00:00.000Z',
end_date: '2010-07-30T21:00:00.000Z',
},
},
],
},
Expand Down Expand Up @@ -572,6 +584,10 @@ const mockData = {
end_date: '2024-07-30T21:00:00.000Z',
start_date: '2017-07-31T21:00:00.000Z',
id: 'hy-opinoik-131106475',
valid: {
start_date: '2020-07-31T21:00:00.000Z',
end_date: '2025-07-30T21:00:00.000Z',
},
},
],
},
Expand Down Expand Up @@ -613,6 +629,10 @@ const mockData = {
end_date: '2024-07-30T21:00:00.000Z',
start_date: '2017-07-31T21:00:00.000Z',
id: 'hy-opinoik-131106475',
valid: {
end_date: '2024-07-30T21:00:00.000Z',
start_date: '2017-07-31T21:00:00.000Z',
},
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions server/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ class User extends Model {
}

async isEnrolled(currentSemester) {
const validNow = ({ startDate, endDate }) => {
const validNow = ({ start_date, end_date }) => {
const today = new Date()
return new Date(startDate) <= today && today <= new Date(endDate)
return new Date(start_date) <= today && today <= new Date(end_date)
}

const studyrights = await this.getStudyRights()
Expand Down
6 changes: 4 additions & 2 deletions server/services/updaterService.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,18 @@ const runAutumnReclaimStatusUpdater = async () => {
await promise // We don't want to spam oodi api so we wait for previous to resolve

try {
const deviceHeldForAYear = currentYear - new Date(student.deviceGivenAt).getFullYear() === 1
const gotDevice = new Date(student.deviceGivenAt).getFullYear()
const deviceHeldForAYear = currentYear - gotDevice === 1
if (deviceHeldForAYear) {
const firstYearCredits = await getFirstYearCredits(student)
await student.update({ firstYearCredits })
}

const creditsUnderLimit = deviceHeldForAYear && student.firstYearCredits < FIRST_YEAR_CREDIT_LIMIT
const absent = await isAbsent(student, getFallSemesterCode(currentYear))
const hadForFiveYears = currentYear - gotDevice === 6

if (absent || creditsUnderLimit) {
if (!hadForFiveYears && (absent || creditsUnderLimit)) {
await ReclaimCase.create({
userId: student.id,
status: 'OPEN',
Expand Down

0 comments on commit fdb09e9

Please sign in to comment.