Skip to content

Commit 633f3d1

Browse files
committed
feat: do not update organization that don't have active repos
1 parent 6e9828e commit 633f3d1

7 files changed

+50
-66
lines changed

server/.sqlx/query-2c34999e86fa60e57a5094eba34e32392087863806ee2138a510e6fdad3da8a1.json

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

server/.sqlx/query-bd5dbdcaa912869a564f97947eab054ed4377d77fbc072fb4db88b2f914c02ee.json

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

server/.sqlx/query-bf43bf73ada19d3b37d7a4d7f638b31f1b29fcf67815d27f10c04e4160082ff2.json

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

server/.sqlx/query-e756f25621a8af624da9273bd3fc49196bba6e249423572e83690b4d02012d46.json

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

server/src/db/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,9 @@ impl DB {
686686
let rec = sqlx::query_as!(
687687
User,
688688
r#"
689-
SELECT login, full_name
689+
SELECT login
690690
FROM users
691+
WHERE full_name IS NULL
691692
FOR UPDATE"#
692693
)
693694
.fetch_all(tx.as_mut())
@@ -702,9 +703,14 @@ impl DB {
702703
let rec = sqlx::query_as!(
703704
User,
704705
r#"
705-
SELECT login, full_name
706-
FROM organizations
707-
FOR UPDATE"#
706+
SELECT DISTINCT login
707+
FROM (
708+
SELECT o.login
709+
FROM organizations o
710+
JOIN repos r ON r.organization_id = o.id
711+
WHERE r.paused = false and o.full_name is null
712+
FOR UPDATE OF o
713+
) subquery"#
708714
)
709715
.fetch_all(tx.as_mut())
710716
.await?;

server/src/db/types.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub struct StreakRecord {
4444
#[derive(Debug, Clone, Serialize, Deserialize)]
4545
pub struct User {
4646
pub login: String,
47-
pub full_name: Option<String>,
4847
}
4948

5049
#[derive(Debug, Clone, Serialize, Deserialize)]

server/src/github_pull.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,6 @@ async fn fetch_missing_user_organization_metadata(
140140
) -> anyhow::Result<()> {
141141
let users = DB::get_users_for_update(tx).await.unwrap_or_default();
142142
for user in users {
143-
if user.full_name.is_some() {
144-
// TODO: add user entry to sync cache
145-
continue;
146-
}
147-
148143
let profile = match github.get_user(&user.login).await {
149144
Ok(profile) => profile,
150145
Err(e) => {
@@ -166,10 +161,6 @@ async fn fetch_missing_user_organization_metadata(
166161
.await
167162
.unwrap_or_default();
168163
for org in orgs {
169-
if org.full_name.is_some() {
170-
continue;
171-
}
172-
173164
let profile = match github.get_user(&org.login).await {
174165
Ok(profile) => profile,
175166
Err(e) => {

0 commit comments

Comments
 (0)