Skip to content

Commit

Permalink
Improved invitation query to return only pending (#177)
Browse files Browse the repository at this point in the history
* feat: improved invitation query to return only pending

* chore: updated clippy
  • Loading branch information
paulobressan authored Oct 17, 2024
1 parent ad3498c commit 5dc8f55
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/driven/cache/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ impl ProjectDrivenCache for SqliteProjectDrivenCache {
page_size: &u32,
) -> Result<Vec<ProjectUserInvite>> {
let offset = page_size * (page - 1);
let status = ProjectUserInviteStatus::Sent.to_string();

let invites = sqlx::query_as::<_, ProjectUserInvite>(
r#"
Expand All @@ -417,15 +418,17 @@ impl ProjectDrivenCache for SqliteProjectDrivenCache {
pui.created_at,
pui.updated_at
FROM project_user_invite pui
WHERE pui.project_id = $1
WHERE pui.project_id = $1 AND DATETIME($5) <= DATETIME(pui.expires_in) AND pui.status = $2
ORDER BY pui.created_at DESC
LIMIT $2
OFFSET $3;
LIMIT $3
OFFSET $4;
"#,
)
.bind(project_id)
.bind(status)
.bind(page_size)
.bind(offset)
.bind(chrono::Utc::now())
.fetch_all(&self.sqlite.db)
.await?;

Expand Down

0 comments on commit 5dc8f55

Please sign in to comment.