Skip to content

Commit

Permalink
add more logging and update kuksa fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Linnea Myllynen committed Apr 27, 2023
1 parent 94723c5 commit 664db13
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
29 changes: 14 additions & 15 deletions src/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,22 @@ module.exports.configurePassport = async (clientUrl) => {

try {
//TODO: Is there a way to not hard code these?
const restrictedAgeGroups = [35, 21, 13] //sudenpennut, seikkailijat, tarpojat
const memberData = await request(
`${process.env.KUKSA}/members/${profile.membernumber}`,
{
json: true,
auth: {
user: process.env.KUKSA_USER,
pass: process.env.KUKSA_PASS,
},
}
)
const url = `${process.env.KUKSA}/members/${profile.membernumber}`
console.log('Kuksa URL: ', url)
const restrictedAgeGroups = [4, 5, 6] //sudenpennut, seikkailijat, tarpojat
const memberData = await request(url, {
json: true,
auth: {
user: process.env.KUKSA_USER,
pass: process.env.KUKSA_PASS,
},
})
console.log('membeData: ', memberData)
console.log('memberData.ageGroupId: ', memberData.ageGroupId)
console.log('memberData.ageGroupId: ', memberData.age_groupId)

let ageGroup = 35 //Sudenpennut
if (memberData.ageGroupId !== null) {
ageGroup = memberData.ageGroupId
let ageGroup = 4 //Sudenpennut
if (memberData.age_groupId !== null) {
ageGroup = memberData.age_groupId
}
console.log('ageGroupId: ', ageGroup)
scout.canMarkDone = !restrictedAgeGroups.includes(ageGroup)
Expand Down
6 changes: 4 additions & 2 deletions src/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ async function getAllGroups(userNumber) {
const groupInfo = await getGroupInfo(userNumber, group.id)
const groupMembers = await getGroupMembers(userNumber, group.id)
const memberData = await getMemberData(groupMembers)
console.log('memberData: ', memberData)
const ageGroupId =
(memberData[0] &&
(await getMember(memberData[0].memberId)).ageGroupId) ||
(await getMember(memberData[0].memberId)).age_groupId) ||
4

return Object.assign(
{},
{
Expand All @@ -70,7 +72,7 @@ async function getAllGroups(userNumber) {
ageGroup: groupInfo.ageGroups[0],
ageGroupId,
troop: groupInfo.troops.filter(
(troop) => troop.id === member.defaultTroopId
(troop) => troop.id === member.default_troop_id
),
members: memberData,
}
Expand Down
7 changes: 4 additions & 3 deletions src/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ export async function getProfile(userNumber) {
{},
{
name: `${member.name.firstname} ${member.name.lastname}`,
defaultTroopId: member.defaultTroopId,
ageGroupId: member.ageGroupId || 35,
ageGroup: member.ageGroup || 'Sudenpennut',
defaultTroopId: member.defaul_troop_id,
ageGroupId: member.age_roupId || 4,
ageGroup: member.age_group || 'Sudenpennut',
language: 'fi',
troops: member.troops,
isLeader: member.isLeader || false,
image: memberImage,
}
)

console.log('PROFILE: ', profile)
return profile
}

0 comments on commit 664db13

Please sign in to comment.