Add : Lab wide attendance aggregate data#153
Open
tejasai2007 wants to merge 3 commits intoamfoss:developfrom
Open
Add : Lab wide attendance aggregate data#153tejasai2007 wants to merge 3 commits intoamfoss:developfrom
tejasai2007 wants to merge 3 commits intoamfoss:developfrom
Conversation
Member
|
hrideshmg
requested changes
Oct 14, 2025
Comment on lines
360
to
394
| r#" | ||
| SELECT | ||
| all_dates.date, | ||
| p.present_count | ||
| FROM ( | ||
| SELECT | ||
| date, | ||
| COUNT(*) AS total_count | ||
| FROM attendance | ||
| WHERE date BETWEEN "#, | ||
| ); | ||
|
|
||
| query.push_bind(start_date); | ||
| query.push(" AND "); | ||
| query.push_bind(end_date); | ||
| query.push(" GROUP BY date ) AS all_dates "); | ||
|
|
||
| // sub query of present members joined with the above total countS | ||
| query.push( | ||
| "LEFT JOIN ( | ||
| SELECT | ||
| date, | ||
| COUNT(*) AS present_count | ||
| FROM attendance | ||
| WHERE is_present = 't' | ||
| AND date BETWEEN ", | ||
| ); | ||
| query.push_bind(start_date); | ||
| query.push(" AND "); | ||
| query.push_bind(end_date); | ||
| query.push( | ||
| " GROUP BY date | ||
| ) AS p | ||
| ON all_dates.date = p.date | ||
| ORDER BY all_dates.date;", |
Member
There was a problem hiding this comment.
Please use the $1, $2 with .bind() syntax to format your SQL. Refer to the other queries in member_queries for examples. The way its formatted right now with multiple push and push_bind's makes it very hard to read.
Will review the SQL logic after its formatted properly.
hrideshmg
reviewed
Nov 13, 2025
Comment on lines
363
to
370
| FROM ( | ||
| SELECT | ||
| date, | ||
| COUNT(*) AS total_count | ||
| FROM attendance | ||
| WHERE date BETWEEN $1 AND $2 | ||
| GROUP BY date | ||
| ) AS all_dates |
Member
There was a problem hiding this comment.
This query is for the attendance summary widget on the Home dashboard which does not need total_count, moreover, total_count isn't even used in the rest of the query. I'm not sure why you need a join here.
Contributor
Author
There was a problem hiding this comment.
You asked me to return null if the count is 0 so i had to join it with all the dates to only present dates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Created a query to get total number of present students in the lab.