Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert changes #63

Merged
merged 4 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions migrations/1671010308952_create-agegroup-completed-table.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports.configurePassport = async (clientUrl) => {

try {
//TODO: Is there a way to not hard code these?
const restrictedAgeGroups = [4, 5, 6] //sudenpennut, seikkailijat, tarpojat
const restrictedAgeGroups = [35, 21, 13] //sudenpennut, seikkailijat, tarpojat
const memberData = await request(
`${process.env.KUKSA}/members/${profile.membernumber}`,
{
Expand All @@ -53,7 +53,7 @@ module.exports.configurePassport = async (clientUrl) => {
}
)

let ageGroup = 4 //Sudenpennut
let ageGroup = 35 //Sudenpennut
if (memberData.ageGroupId !== null) {
ageGroup = memberData.ageGroupId
}
Expand Down
49 changes: 0 additions & 49 deletions src/database/ageGroups.js

This file was deleted.

12 changes: 0 additions & 12 deletions src/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
getGroupMembers,
} from './kuksa'
import { getTaskEntries, getTaskGroupEntries } from './database'
import { getAgeGroupEntries } from './database/ageGroups'

async function getMemberData(groupMembers) {
return Promise.all(
Expand All @@ -14,9 +13,6 @@ async function getMemberData(groupMembers) {
const allMemberTaskGroupEntries = await getTaskGroupEntries(
groupMember.id.id
)
const allMemberAgeGroupEntries = await getAgeGroupEntries(
groupMember.id.id
)
const taskEntries = allMemberTaskEntries.reduce((acc, task) => {
acc[task.task_guid] = task.completion_status
return acc
Expand All @@ -28,13 +24,6 @@ async function getMemberData(groupMembers) {
},
{}
)
const ageGroupEntries = allMemberAgeGroupEntries.reduce(
(acc, agegroup) => {
acc[agegroup.agegroup_guid] = agegroup.completion_status
return acc
},
{}
)
return Object.assign(
{},
{
Expand All @@ -44,7 +33,6 @@ async function getMemberData(groupMembers) {
groupMember.name.firstname + ' ' + groupMember.name.lastname,
memberTasks: taskEntries,
memberTaskGroups: taskgroupEntries,
memberAgeGroups: ageGroupEntries,
}
)
})
Expand Down
40 changes: 0 additions & 40 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import taskGroups from './taskGroups'
import { deleteOldNotifications } from './database/notifications'
import https from 'https'
import fs from 'fs'
import { postAgegroupEntry, getAgeGroupEntries } from './database/ageGroups'

require('dotenv').config()

Expand Down Expand Up @@ -160,45 +159,6 @@ const main = async () => {
})
})

app.post(
'/groups/mark-agegroup-done/:agegroup_guid',
isLoggedIn,
isGroupLeader,
async (req, res) => {
try {
const userData = req.body
const promises = Object.values(userData.groups).map((userIds) => {
const promises = userIds.map((user_guid) =>
Promise.resolve(
postAgegroupEntry({
user_guid: Number(user_guid),
created_by: Number(req.user.membernumber),
agegroup_guid: req.params.agegroup_guid,
completed: 'COMPLETED',
group_leader_name: userData.group_leader_name,
})
)
)
return promises
})
const iterablePromises = [].concat.apply([], promises)
const entries = await Promise.all(iterablePromises)
res.json(entries).status(200)
} catch (e) {
res.status(e.statusCode).send(e.message)
}
}
)

app.get('/agegroup-entries', isLoggedIn, async (req, res) => {
try {
const entries = await getAgeGroupEntries(req.user.membernumber)
res.json(entries).status(200)
} catch (e) {
res.status(e.statusCode).send(e.message)
}
})

app.post('/task-entry', isLoggedIn, async (req, res) => {
try {
const data = req.body
Expand Down
2 changes: 1 addition & 1 deletion src/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function getProfile(userNumber) {
{
name: `${member.name.firstname} ${member.name.lastname}`,
defaultTroopId: member.defaultTroopId,
ageGroupId: member.ageGroupId || 4,
ageGroupId: member.ageGroupId || 35,
ageGroup: member.ageGroup || 'Sudenpennut',
language: 'fi',
troops: member.troops,
Expand Down
35 changes: 0 additions & 35 deletions src/scripts/delete-activities-by-id.js

This file was deleted.

106 changes: 0 additions & 106 deletions src/scripts/get-unused-activities.js

This file was deleted.

Loading