Compare commits

..

No commits in common. "master" and "crawl-forgeflux" have entirely different histories.

6 changed files with 69 additions and 72 deletions

View file

@ -18,9 +18,9 @@ COPY . .
COPY --from=cacher /src/target target COPY --from=cacher /src/target target
RUN make release RUN make release
FROM debian:latest FROM debian:bullseye-slim
#LABEL org.opencontainers.image.source https://github.com/forgeflux-org/starchart LABEL org.opencontainers.image.source https://github.com/forgeflux-org/starchart
RUN apt-get update && apt-get install -y ca-certificates libssl-dev RUN apt-get update && apt-get install -y ca-certificates
COPY --from=builder /src/target/release/starchart /usr/local/bin/ COPY --from=builder /src/target/release/starchart /usr/local/bin/
COPY --from=builder /src/config/default.toml /etc/starchart/config.toml COPY --from=builder /src/config/default.toml /etc/starchart/config.toml
COPY scripts/entrypoint.sh /usr/local/bin COPY scripts/entrypoint.sh /usr/local/bin

View file

@ -98,11 +98,11 @@ doc: ## Prepare documentation
cargo doc --no-deps --workspace --all-features cargo doc --no-deps --workspace --all-features
docker: ## Build docker images docker: ## Build docker images
docker build -t forgeflux/starchart:master -t forgeflux/starchart:latest . docker build -t forgedfed/starchart:master -t forgedfed/starchart:latest .
docker-publish: docker ## Build and publish docker images docker-publish: docker ## Build and publish docker images
docker push forgeflux/starchart:master docker push forgedfed/starchart:master
docker push forgeflux/starchart:latest docker push forgedfed/starchart:latest
lint: ## Lint codebase lint: ## Lint codebase
cargo fmt -v --all -- --emit files cargo fmt -v --all -- --emit files

View file

@ -1 +0,0 @@
INSERT OR IGNORE INTO starchart_forge_type (name) VALUES('forgeflux');

View file

@ -18,6 +18,16 @@
}, },
"query": "SELECT\n starchart_introducer.instance_url\n FROM \n starchart_federated_mini_index\n INNER JOIN\n starchart_introducer\n ON\n starchart_introducer.ID = starchart_instance \n WHERE\n mini_index MATCH $1" "query": "SELECT\n starchart_introducer.instance_url\n FROM \n starchart_federated_mini_index\n INNER JOIN\n starchart_introducer\n ON\n starchart_introducer.ID = starchart_instance \n WHERE\n mini_index MATCH $1"
}, },
"069a127ffb1062321bba5a915a4ead3e0bbe4dabf6e0f684d8cc6a6d8a68ad5b": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 4
}
},
"query": "INSERT OR IGNORE INTO fts_repositories ( name, description, website, html_url ) \n VALUES ( $1, $2, $3, $4 );"
},
"0b179588df37779f563f0ad8c43e920a8bc22b3eed682778cef9dd05608f9691": { "0b179588df37779f563f0ad8c43e920a8bc22b3eed682778cef9dd05608f9691": {
"describe": { "describe": {
"columns": [ "columns": [
@ -94,26 +104,6 @@
}, },
"query": "SELECT html_url, profile_photo_html_url, imported FROM starchart_users WHERE username = $1 AND \n hostname_id = (SELECT ID FROM starchart_forges WHERE hostname = $2)" "query": "SELECT html_url, profile_photo_html_url, imported FROM starchart_users WHERE username = $1 AND \n hostname_id = (SELECT ID FROM starchart_forges WHERE hostname = $2)"
}, },
"1f47bff0270cfb9d58972ecf6ae36f348d9f605a40a8669ce2908b50a3aac735": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 4
}
},
"query": "INSERT OR REPLACE INTO fts_repositories ( name, description, website, html_url ) \n VALUES ( $1, $2, $3, $4 );"
},
"2ac627ddd905bab19582037ca5e402ebaa268b61d94459e125644028d04e6dc2": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 4
}
},
"query": "INSERT OR REPLACE INTO starchart_forges\n (hostname, verified_on, forge_type, starchart_instance)\n VALUES (\n $1,\n $2,\n (SELECT ID FROM starchart_forge_type WHERE name = $3),\n (SELECT ID FROM starchart_introducer WHERE instance_url = $4)\n )"
},
"2afb17ba3753aa440465a836b46b7a1466f25791cfc4d0acdd38bc2755ae3e86": { "2afb17ba3753aa440465a836b46b7a1466f25791cfc4d0acdd38bc2755ae3e86": {
"describe": { "describe": {
"columns": [ "columns": [
@ -150,6 +140,16 @@
}, },
"query": "SELECT ID FROM starchart_forge_type WHERE name = $1" "query": "SELECT ID FROM starchart_forge_type WHERE name = $1"
}, },
"338fb30307071e6df9efee6a68697c60e579d7b2332630bce401c0e7186a642a": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 7
}
},
"query": "INSERT INTO \n starchart_users (\n hostname_id, username, html_url,\n profile_photo_html_url, added_on, last_crawl_on, imported\n ) \n VALUES (\n (SELECT ID FROM starchart_forges WHERE hostname = $1), $2, $3, $4, $5, $6, $7)"
},
"364c8e3d147318b864fd28ad284f225aaace9479b5cf0428fb97f0e5689e248d": { "364c8e3d147318b864fd28ad284f225aaace9479b5cf0428fb97f0e5689e248d": {
"describe": { "describe": {
"columns": [], "columns": [],
@ -224,16 +224,6 @@
}, },
"query": "SELECT\n hostname,\n last_crawl_on,\n starchart_introducer.instance_url,\n starchart_forge_type.name\n FROM\n starchart_forges\n INNER JOIN\n starchart_forge_type\n ON\n starchart_forges.forge_type = starchart_forge_type.id\n LEFT JOIN\n starchart_introducer\n ON\n starchart_introducer.ID = starchart_forges.starchart_instance\n WHERE \n starchart_forges.imported = 0\n ORDER BY\n starchart_forges.ID\n LIMIT $1 OFFSET $2;\n " "query": "SELECT\n hostname,\n last_crawl_on,\n starchart_introducer.instance_url,\n starchart_forge_type.name\n FROM\n starchart_forges\n INNER JOIN\n starchart_forge_type\n ON\n starchart_forges.forge_type = starchart_forge_type.id\n LEFT JOIN\n starchart_introducer\n ON\n starchart_introducer.ID = starchart_forges.starchart_instance\n WHERE \n starchart_forges.imported = 0\n ORDER BY\n starchart_forges.ID\n LIMIT $1 OFFSET $2;\n "
}, },
"6c6a24873ae0053df5b875a35ed8c605e73c9718951b87140d2cada093ec4cf6": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 9
}
},
"query": "INSERT OR REPLACE INTO \n starchart_repositories (\n hostname_id, owner_id, name, description, html_url, website, created,\n last_crawl, imported\n )\n VALUES (\n (SELECT ID FROM starchart_forges WHERE hostname = $1),\n (SELECT ID FROM starchart_users WHERE username = $2),\n $3, $4, $5, $6, $7, $8, $9\n );"
},
"6f5ca3d71a541eb6f33e37a5889c048536ab6ad7e81a6236d73aa71433c13717": { "6f5ca3d71a541eb6f33e37a5889c048536ab6ad7e81a6236d73aa71433c13717": {
"describe": { "describe": {
"columns": [], "columns": [],
@ -244,6 +234,16 @@
}, },
"query": "INSERT OR IGNORE INTO starchart_project_topics ( name ) VALUES ( $1 );" "query": "INSERT OR IGNORE INTO starchart_project_topics ( name ) VALUES ( $1 );"
}, },
"74fb3a1ae4f339b5371a6872e6eb4ed7c1f5968dac70de1639454c394a05cb38": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 4
}
},
"query": "INSERT INTO starchart_forges\n (hostname, verified_on, forge_type, starchart_instance)\n VALUES\n (\n $1, $2,\n (SELECT ID FROM starchart_forge_type WHERE name = $3),\n $4)"
},
"7590630f5fe7e05014b70ac0047f9b6c724b88e35e1b1306fb89760612929d55": { "7590630f5fe7e05014b70ac0047f9b6c724b88e35e1b1306fb89760612929d55": {
"describe": { "describe": {
"columns": [], "columns": [],
@ -424,16 +424,6 @@
}, },
"query": "SELECT name FROM starchart_project_topics ORDER BY ID LIMIT $1 OFFSET $2;" "query": "SELECT name FROM starchart_project_topics ORDER BY ID LIMIT $1 OFFSET $2;"
}, },
"a754fb4bcdd227f3ab440c5600a534dcabde3e75ea242a530d6aa12c7502c88e": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 7
}
},
"query": "INSERT OR REPLACE INTO \n starchart_users (\n hostname_id, username, html_url,\n profile_photo_html_url, added_on, last_crawl_on, imported\n ) \n VALUES (\n (SELECT ID FROM starchart_forges WHERE hostname = $1), $2, $3, $4, $5, $6, $7)"
},
"a81dd4b5df666e22fac211092e7b8425d838dd9023aa2b17659352f30831944d": { "a81dd4b5df666e22fac211092e7b8425d838dd9023aa2b17659352f30831944d": {
"describe": { "describe": {
"columns": [ "columns": [
@ -452,6 +442,16 @@
}, },
"query": "SELECT ID FROM starchart_users WHERE username = $1 AND \n hostname_id = (SELECT ID FROM starchart_forges WHERE hostname = $2)" "query": "SELECT ID FROM starchart_users WHERE username = $1 AND \n hostname_id = (SELECT ID FROM starchart_forges WHERE hostname = $2)"
}, },
"a912406491a4e9ea1bbf8a3d0003e948a24df7f101c490aca395f5b86ec64d00": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 4
}
},
"query": "INSERT OR IGNORE INTO starchart_forges\n (hostname, verified_on, forge_type, starchart_instance)\n VALUES (\n $1,\n $2,\n (SELECT ID FROM starchart_forge_type WHERE name = $3),\n (SELECT ID FROM starchart_introducer WHERE instance_url = $4)\n )"
},
"ae9295f46da1753fe91a633b5738533084005ad32915c19635f896c454284b6b": { "ae9295f46da1753fe91a633b5738533084005ad32915c19635f896c454284b6b": {
"describe": { "describe": {
"columns": [ "columns": [
@ -522,6 +522,16 @@
}, },
"query": "INSERT OR IGNORE INTO\n starchart_imported_starcharts (starchart_instance)\n VALUES ((SELECT ID FROM starchart_introducer WHERE instance_url = $1));" "query": "INSERT OR IGNORE INTO\n starchart_imported_starcharts (starchart_instance)\n VALUES ((SELECT ID FROM starchart_introducer WHERE instance_url = $1));"
}, },
"ca22e5f6e7065cf2d4ffdbfac0084f9871de8cd9073d470cbf7eac2de2a73c47": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 9
}
},
"query": "INSERT INTO \n starchart_repositories (\n hostname_id, owner_id, name, description, html_url, website, created,\n last_crawl, imported\n )\n VALUES (\n (SELECT ID FROM starchart_forges WHERE hostname = $1),\n (SELECT ID FROM starchart_users WHERE username = $2),\n $3, $4, $5, $6, $7, $8, $9\n );"
},
"d22d18f0c2b49a570ac95e1af5ba398b3d1c7a1a5a6780d6dc646077e466714c": { "d22d18f0c2b49a570ac95e1af5ba398b3d1c7a1a5a6780d6dc646077e466714c": {
"describe": { "describe": {
"columns": [ "columns": [
@ -680,16 +690,6 @@
}, },
"query": "SELECT word FROM starchart_mini_index" "query": "SELECT word FROM starchart_mini_index"
}, },
"fc32b8d0e5599dcc1ceed4127ca860d09754dd6d1fe558fbe5c7f4086c901b8f": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 4
}
},
"query": "INSERT OR REPLACE INTO starchart_forges\n (hostname, verified_on, forge_type, starchart_instance)\n VALUES\n (\n $1, $2,\n (SELECT ID FROM starchart_forge_type WHERE name = $3),\n $4)"
},
"fdf87490759150d528139b13eb1a28532b5bebb546ade00bcb6a7d648abcd445": { "fdf87490759150d528139b13eb1a28532b5bebb546ade00bcb6a7d648abcd445": {
"describe": { "describe": {
"columns": [], "columns": [],

View file

@ -160,7 +160,7 @@ impl Database {
return Ok(()); return Ok(());
} }
sqlx::query!( sqlx::query!(
"INSERT OR REPLACE INTO fts_repositories ( name, description, website, html_url ) "INSERT OR IGNORE INTO fts_repositories ( name, description, website, html_url )
VALUES ( $1, $2, $3, $4 );", VALUES ( $1, $2, $3, $4 );",
name, name,
description, description,
@ -313,7 +313,7 @@ impl SCDatabase for Database {
let forge_type = f.forge_type.to_str(); let forge_type = f.forge_type.to_str();
if let Some(instance_url) = f.starchart_url { if let Some(instance_url) = f.starchart_url {
sqlx::query!( sqlx::query!(
"INSERT OR REPLACE INTO starchart_forges "INSERT OR IGNORE INTO starchart_forges
(hostname, verified_on, forge_type, starchart_instance) (hostname, verified_on, forge_type, starchart_instance)
VALUES ( VALUES (
$1, $1,
@ -331,7 +331,7 @@ impl SCDatabase for Database {
.map_err(map_register_err)?; .map_err(map_register_err)?;
} else { } else {
sqlx::query!( sqlx::query!(
"INSERT OR REPLACE INTO starchart_forges "INSERT INTO starchart_forges
(hostname, verified_on, forge_type, starchart_instance) (hostname, verified_on, forge_type, starchart_instance)
VALUES VALUES
( (
@ -491,7 +491,7 @@ impl SCDatabase for Database {
let now = now_unix_time_stamp(); let now = now_unix_time_stamp();
let url = db_core::clean_url(&u.url); let url = db_core::clean_url(&u.url);
sqlx::query!( sqlx::query!(
"INSERT OR REPLACE INTO "INSERT INTO
starchart_users ( starchart_users (
hostname_id, username, html_url, hostname_id, username, html_url,
profile_photo_html_url, added_on, last_crawl_on, imported profile_photo_html_url, added_on, last_crawl_on, imported
@ -607,7 +607,7 @@ impl SCDatabase for Database {
let now = now_unix_time_stamp(); let now = now_unix_time_stamp();
let url = db_core::clean_url(&r.url); let url = db_core::clean_url(&r.url);
sqlx::query!( sqlx::query!(
"INSERT OR REPLACE INTO "INSERT INTO
starchart_repositories ( starchart_repositories (
hostname_id, owner_id, name, description, html_url, website, created, hostname_id, owner_id, name, description, html_url, website, created,
last_crawl, imported last_crawl, imported

View file

@ -92,7 +92,7 @@ impl SCForge for ForgeFlux {
let tags = Tags::default(); let tags = Tags::default();
let mut users = UserMap::default(); let mut users = UserMap::default();
let mut internal_users = UserMap::default(); let internal_users = UserMap::default();
let mut repos = Repositories::default(); let mut repos = Repositories::default();
let instance_url = self.instance_url.clone(); let instance_url = self.instance_url.clone();
@ -112,7 +112,7 @@ impl SCForge for ForgeFlux {
let mut sleep_fut: Option<JoinHandle<()>> = None; let mut sleep_fut: Option<JoinHandle<()>> = None;
for repo in res.drain(0..) { for repo in res.drain(0..) {
let user = { //if internal_users.contains_key(&repo.attributed_to.to_string()) { let user = if internal_users.contains_key(&repo.attributed_to.to_string()) {
if let Some(sleep_fut) = sleep_fut { if let Some(sleep_fut) = sleep_fut {
sleep_fut.await.unwrap(); sleep_fut.await.unwrap();
} }
@ -146,18 +146,16 @@ impl SCForge for ForgeFlux {
users.insert(f_user.username.clone(), f_user.clone()); users.insert(f_user.username.clone(), f_user.clone());
users.insert(Arc::new(f_user.url.to_string()), f_user.clone()); users.insert(Arc::new(f_user.url.to_string()), f_user.clone());
internal_users.insert(Arc::new(repo.attributed_to.to_string()), f_user.clone());
f_user f_user
} else {
internal_users
.get(&repo.attributed_to.to_string())
.unwrap()
.clone()
}; };
// } else {
// internal_users
// .get(&repo.attributed_to.to_string())
// .unwrap()
// .clone()
// };
let frepo = Repository { let frepo = Repository {
url: repo.id.clone(), url: self.url.clone(),
website: None, website: None,
name: repo.name, name: repo.name,
owner: user, owner: user,