Skip to content

Commit

Permalink
refactor: new api from sparcs-ar
Browse files Browse the repository at this point in the history
  • Loading branch information
pbc1017 committed Mar 17, 2024
1 parent 42a071e commit 63627dc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions back/routes/new/clubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ const {
RegistrationMember,
} = require("../../models");

async function getClubRepresentative(clubId, currentDate) {
const clubRepresentative = await ClubRepresentative.findOne({
where: {
club_id: clubId,
type_id: 1,
start_term: { [Op.lte]: currentDate },
[Op.or]: [{ end_term: { [Op.gte]: currentDate } }, { end_term: null }],
},
});
if (clubRepresentative) {
const presidentMember = await Member.findByPk(
clubRepresentative.student_id
);
return presidentMember ? presidentMember.name : "";
}
return "";
}

router.get("/", async (req, res) => {
try {
// Get the current semester
Expand Down

0 comments on commit 63627dc

Please sign in to comment.