-
Notifications
You must be signed in to change notification settings - Fork 20
Major Refactor #143
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
+195
−497
Merged
Major Refactor #143
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
54927c4
refactor: remove unused queries
hrideshmg 7ceb00c
refactor: move attendance to all_members query
hrideshmg b3d07b3
refactor: aggregate queries into member object
hrideshmg dcf745e
refactor!: Overhaul status update mutations
hrideshmg 41c4de9
refactor: move streak calculation to database layer
hrideshmg 601d667
chore: remove unnecessary tables
hrideshmg a341ea9
refactor: give models a consistent naming scheme
hrideshmg e4d3c86
feat: implement batch status update mutation
hrideshmg 9deda14
refactor: rename column on statusupdatehistory
hrideshmg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- Add migration script here | ||
DROP TABLE statusupdatestreak; | ||
DROP TABLE project; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- Add migration script here | ||
ALTER table statusupdatehistory | ||
RENAME COLUMN is_updated TO is_sent; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,12 @@ | ||
use async_graphql::MergedObject; | ||
use mutations::{AttendanceMutations, MemberMutations, ProjectMutations, StreakMutations}; | ||
use queries::{AttendanceQueries, MemberQueries, ProjectQueries, StreakQueries}; | ||
use mutations::{AttendanceMutations, MemberMutations, StatusMutations}; | ||
use queries::MemberQueries; | ||
|
||
pub mod mutations; | ||
pub mod queries; | ||
|
||
#[derive(MergedObject, Default)] | ||
pub struct Query( | ||
MemberQueries, | ||
AttendanceQueries, | ||
StreakQueries, | ||
ProjectQueries, | ||
); | ||
pub struct Query(MemberQueries); | ||
|
||
#[derive(MergedObject, Default)] | ||
pub struct Mutation( | ||
MemberMutations, | ||
AttendanceMutations, | ||
StreakMutations, | ||
ProjectMutations, | ||
); | ||
pub struct Mutation(MemberMutations, AttendanceMutations, StatusMutations); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
pub mod attendance_mutations; | ||
pub mod member_mutations; | ||
pub mod project_mutations; | ||
pub mod streak_mutations; | ||
pub mod status_mutations; | ||
|
||
pub use attendance_mutations::AttendanceMutations; | ||
pub use member_mutations::MemberMutations; | ||
pub use project_mutations::ProjectMutations; | ||
pub use streak_mutations::StreakMutations; | ||
pub use status_mutations::StatusMutations; |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use async_graphql::{Context, Object, Result}; | ||
use chrono_tz::Asia::Kolkata; | ||
use sqlx::PgPool; | ||
use std::sync::Arc; | ||
|
||
use crate::models::status_update::StatusUpdateRecord; | ||
|
||
#[derive(Default)] | ||
pub struct StatusMutations; | ||
|
||
#[Object] | ||
impl StatusMutations { | ||
async fn mark_status_update( | ||
&self, | ||
ctx: &Context<'_>, | ||
emails: Vec<String>, | ||
) -> Result<Vec<StatusUpdateRecord>> { | ||
let pool = ctx.data::<Arc<PgPool>>().expect("Pool must be in context"); | ||
#[allow(deprecated)] | ||
hrideshmg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let yesterday = chrono::Utc::now() | ||
.with_timezone(&Kolkata) | ||
.date() | ||
.naive_local() | ||
- chrono::Duration::days(1); | ||
|
||
let status = sqlx::query_as::<_, StatusUpdateRecord>( | ||
"UPDATE StatusUpdateHistory SET | ||
is_sent = true | ||
WHERE member_id IN (SELECT member_id from Member where email = ANY($1)) | ||
AND date = $2 | ||
RETURNING * | ||
", | ||
) | ||
.bind(emails) | ||
.bind(yesterday) | ||
.fetch_all(pool.as_ref()) | ||
.await?; | ||
|
||
Ok(status) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.