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

✨ feat: used proc #66

Merged
merged 1 commit into from
Dec 29, 2023
Merged
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
14 changes: 9 additions & 5 deletions server/middlewares/current.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import db from '../database/db.js'
const getCurrentTermMiddleware = async (req, res, next) => {
try {
const result = await db.query(
`SELECT * FROM "Term" WHERE "termNumber" IN
(SELECT COALESCE(MAX("termNumber"), 0) FROM "Term");`
`CALL "getCurrentTerm"($1, $2, $3, $4);`,
[null, null, null, null]
)
if (!result.rows.length) {
req.currentTerm = {
Expand All @@ -23,10 +23,14 @@ const getCurrentTermMiddleware = async (req, res, next) => {

const getCurrentWeekMiddleware = async (req, res, next) => {
try {
// const result = await db.query(
// `SELECT * FROM "Week" WHERE "weekNumber" IN
// (SELECT COALESCE(MAX("weekNumber"), 0) FROM "Week" WHERE "termNumber" IN
// (SELECT COALESCE(MAX("termNumber"), 0) FROM "Term"));`
// )
const result = await db.query(
`SELECT * FROM "Week" WHERE "weekNumber" IN
(SELECT COALESCE(MAX("weekNumber"), 0) FROM "Week" WHERE "termNumber" IN
(SELECT COALESCE(MAX("termNumber"), 0) FROM "Term"));`
`CALL "getCurrentWeek"($1, $2, $3, $4);`,
[null, null, null, null]
)
if (!result.rows.length) {
req.currentWeek = {
Expand Down