Skip to content

Commit 03324a4

Browse files
committed
rewrite graphql interface
This commit changes a lot more things than just the graphql interface. Also likely introduces a few extra regressions. ¯\_(ツ)_/¯
1 parent 7762c85 commit 03324a4

23 files changed

+586
-473
lines changed

Cargo.lock

Lines changed: 31 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ serde_json = "1.0"
2121
reqwest = { version = "0.11.27", features = ["json"] }
2222
config = "0.13"
2323
tracing = "0.1.41"
24-
tracing-subscriber = "0.3.19"
24+
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
2525
dotenv = "0.15.0"

migrations/20250114180047_create_tables.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ CREATE TABLE Attendance (
3232
(is_present = FALSE AND time_in IS NULL AND time_out IS NULL)
3333
),
3434
CHECK (is_present = FALSE OR date <= CURRENT_DATE),
35-
CHECK (time_out IS NULL OR time_out > time_in),
35+
CHECK (time_out IS NULL OR time_out >= time_in),
3636
UNIQUE (member_id, date)
3737
);
3838

@@ -58,7 +58,7 @@ CREATE TABLE AttendanceSummary (
5858
primary key (member_id, year, month)
5959
);
6060

61-
CREATE TABLE StatusUpdateStreaks (
61+
CREATE TABLE StatusUpdateStreak (
6262
member_id INT REFERENCES Member(member_id) ON DELETE CASCADE,
6363
current_streak int NOT NULL DEFAULT 0,
6464
max_streak INT NOT NULL,

src/attendance/daily_task.rs renamed to src/daily_task/daily_task.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use chrono::{Datelike, Local, NaiveDate, NaiveTime};
22
use chrono_tz::Asia::Kolkata;
33
use sqlx::PgPool;
44
use std::sync::Arc;
5-
use tracing::{debug, error, info, trace};
5+
use tracing::{debug, error};
66

77
use crate::models::member::Member;
88

@@ -26,7 +26,7 @@ pub async fn execute_daily_task(pool: Arc<PgPool>) {
2626
// We need to add a record for every member because otherwise [`Presense`](https://www.github.com/presense) will only add present members to the DB, and we will have to JOIN Members and Attendance records for the day to get the absent members. In exchange for increased storage use, we get simpler queries for Home which needs the data for every member for every day so far. But as of Jan 2025, there are less than 50 members in the club and thus storage really shouldn't be an issue.
2727
/// Inserts new attendance records everyday for [`presense`](https://www.github.com/amfoss/presense) to update them later in the day and updates the AttendanceSummary table to keep track of monthly streaks.
2828
async fn update_attendance(members: Vec<Member>, pool: &PgPool) {
29-
info!("Updating attendance...");
29+
debug!("Updating attendance...");
3030
let today = Local::now().with_timezone(&Kolkata).date_naive();
3131

3232
for member in members {
@@ -66,7 +66,7 @@ async fn update_attendance(members: Vec<Member>, pool: &PgPool) {
6666

6767
/// Checks if the member was present yesterday, and if so, increments the `days_attended` value. Otherwise, do nothing.
6868
async fn update_attendance_summary(member_id: i32, pool: &PgPool) {
69-
trace!("Updating summary for member #{}", member_id);
69+
debug!("Updating summary for member #{}", member_id);
7070
let today = chrono::Local::now().with_timezone(&Kolkata).date_naive();
7171
let yesterday = today.checked_sub_signed(chrono::Duration::days(1)).unwrap(); // Get yesterday's date
7272

File renamed without changes.

src/graphql/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pub mod mutations;
2-
pub mod query;
2+
pub mod queries;

src/graphql/mutations.rs

Lines changed: 0 additions & 273 deletions
This file was deleted.

0 commit comments

Comments
 (0)