-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
299 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 @@ | ||
CREATE INDEX user_pagerank_idx FOR (u:User) ON (u.pagerank); |
This file contains 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,49 @@ | ||
use anyhow::{Context, Result}; | ||
use neo4rs::Graph; | ||
use nos_followers::{ | ||
config::{Config, Settings}, | ||
repo::{Repo, RepoTrait}, | ||
}; | ||
use std::sync::Arc; | ||
use tracing::{error, info}; | ||
use tracing_subscriber::{fmt, prelude::*, EnvFilter}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
// Initialize logging | ||
tracing_subscriber::registry() | ||
.with(fmt::layer()) | ||
.with(EnvFilter::from_default_env()) | ||
.init(); | ||
|
||
info!("PageRank updater started"); | ||
|
||
// Load configuration | ||
let config = Config::new("config").context("Loading configuration failed")?; | ||
let settings = config | ||
.get::<Settings>() | ||
.context("Retrieving settings from configuration failed")?; | ||
|
||
// Connect to Neo4j | ||
info!("Connecting to Neo4j at {}", settings.neo4j_uri); | ||
let graph = Graph::new( | ||
&settings.neo4j_uri, | ||
&settings.neo4j_user, | ||
&settings.neo4j_password, | ||
) | ||
.await | ||
.context("Failed to connect to Neo4j")?; | ||
|
||
// Initialize Repo | ||
let repo = Arc::new(Repo::new(graph)); | ||
|
||
// Execute PageRank | ||
info!("Executing PageRank update"); | ||
if let Err(e) = repo.update_pagerank().await { | ||
error!("PageRank update failed: {:?}", e); | ||
return Err(e).context("PageRank update encountered an error"); | ||
} | ||
|
||
info!("PageRank update completed successfully"); | ||
Ok(()) | ||
} |
This file contains 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 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 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 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 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
Oops, something went wrong.