Skip to content

Commit

Permalink
Return both teacher and student classrooms
Browse files Browse the repository at this point in the history
  • Loading branch information
jzongker committed Apr 22, 2024
1 parent 69fdcbf commit 56152dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/controllers/ClassroomController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class ClassroomController extends LessonsBaseController {
@httpGet("/person")
public async getForPerson(@requestParam("churchId") churchId: string, req: express.Request<{}, {}, null>, res: express.Response): Promise<interfaces.IHttpActionResult> {
return this.actionWrapper(req, res, async (au) => {
return await this.repositories.classroom.loadForPerson(au.churchId, au.groupIds, req.query.upcoming === "1");
return await this.repositories.classroom.loadForPerson(au.churchId, au.groupIds);
});
}

Expand Down
7 changes: 3 additions & 4 deletions src/repositories/ClassroomRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ export class ClassroomRepository {
return classroom;
}

public loadForPerson(churchId: string, groupIds:string[], upcoming:boolean): Promise<Classroom[]> {
let sql = "SELECT * FROM classrooms WHERE churchId=? AND recentGroupId IN (?) ORDER BY name";
if (upcoming) sql = "SELECT * FROM classrooms WHERE churchId=? AND upcomingGroupId IN (?) ORDER BY name";
return DB.query(sql, [churchId, groupIds]);
public loadForPerson(churchId: string, groupIds:string[]): Promise<Classroom[]> {
const sql = "SELECT * FROM classrooms WHERE churchId=? AND (recentGroupId IN (?) OR upcomingGroupId IN (?)) ORDER BY name";
return DB.query(sql, [churchId, groupIds, groupIds]);
}

public loadByChurchId(churchId: string): Promise<Classroom[]> {
Expand Down

0 comments on commit 56152dd

Please sign in to comment.