Skip to content

Conversation

@tejasai2007
Copy link
Contributor

Created a query to get total number of present students in the lab.

@ivinjabraham
Copy link
Member

  1. Please link your PRs with an existing issue. If there isn't one, create one beforehand.
  2. Don't use commit messages and PR bodies to just state what you have done, state why.

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;",
Copy link
Member

@hrideshmg hrideshmg Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants