diff --git a/db/db-sqlx-sqlite/sqlx-data.json b/db/db-sqlx-sqlite/sqlx-data.json
index 6e00d2e..70ce312 100644
--- a/db/db-sqlx-sqlite/sqlx-data.json
+++ b/db/db-sqlx-sqlite/sqlx-data.json
@@ -196,6 +196,36 @@
},
"query": "INSERT INTO\n starchart_forges (hostname, verified_on, forge_type ) \n VALUES ($1, $2, (SELECT ID FROM starchart_forge_type WHERE name = $3))"
},
+ "a4e02e0fafe95a6e21347607f5f69a06f592c3624775feadaaf5fa5b4285815d": {
+ "describe": {
+ "columns": [
+ {
+ "name": "hostname",
+ "ordinal": 0,
+ "type_info": "Text"
+ },
+ {
+ "name": "last_crawl_on",
+ "ordinal": 1,
+ "type_info": "Int64"
+ },
+ {
+ "name": "name",
+ "ordinal": 2,
+ "type_info": "Text"
+ }
+ ],
+ "nullable": [
+ false,
+ true,
+ false
+ ],
+ "parameters": {
+ "Right": 1
+ }
+ },
+ "query": "SELECT \n\t\thostname,\n\t\tlast_crawl_on,\n\t\tstarchart_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 WHERE\n hostname = $1;\n "
+ },
"a75419ce6d1248944a7bdd63ddadd6f1017a27b8490fb2746a0f7a5d35ce889a": {
"describe": {
"columns": [],
diff --git a/db/db-sqlx-sqlite/src/lib.rs b/db/db-sqlx-sqlite/src/lib.rs
index c705cc9..4bf3249 100644
--- a/db/db-sqlx-sqlite/src/lib.rs
+++ b/db/db-sqlx-sqlite/src/lib.rs
@@ -15,6 +15,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
+use std::str::FromStr;
+
use db_core::dev::*;
use sqlx::sqlite::SqlitePool;
@@ -140,6 +142,43 @@ impl SCDatabase for Database {
Ok(())
}
+ /// get forge isntance data
+ async fn get_forge(&self, hostname: &str) -> DBResult {
+ struct InnerForge {
+ hostname: String,
+ last_crawl_on: Option,
+ name: String,
+ }
+ let f = sqlx::query_as!(
+ InnerForge,
+ "SELECT
+ hostname,
+ last_crawl_on,
+ starchart_forge_type.name
+ FROM
+ starchart_forges
+ INNER JOIN
+ starchart_forge_type
+ ON
+ starchart_forges.forge_type = starchart_forge_type.id
+ WHERE
+ hostname = $1;
+ ",
+ hostname,
+ )
+ .fetch_one(&self.pool)
+ .await
+ .map_err(|e| DBError::DBError(Box::new(e)))?;
+
+ let f = Forge {
+ hostname: f.hostname,
+ last_crawl_on: f.last_crawl_on,
+ forge_type: ForgeImplementation::from_str(&f.name).unwrap(),
+ };
+
+ Ok(f)
+ }
+
/// check if a forge instance exists
async fn forge_exists(&self, hostname: &str) -> DBResult {
match sqlx::query!(