Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Aug 3, 2024
1 parent 66312c2 commit a400fcf
Showing 1 changed file with 24 additions and 139 deletions.
163 changes: 24 additions & 139 deletions Summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -2235,7 +2235,7 @@ index bdae5d9..85ac6fa 100644
+++ b/Cargo.toml
+ chrono = "0.4.38"
diff --git a/Source/Fn/Summary.rs b/Source/Fn/Summary.rs
index b904dbd..f42cdc8 100644
index b904dbd..d6728f0 100644
--- a/Source/Fn/Summary.rs
+++ b/Source/Fn/Summary.rs
- /// * `Entry` - A string slice representing the path to the git repository.
Expand All @@ -2244,153 +2244,38 @@ index b904dbd..f42cdc8 100644
+ /// * Option - A reference to a struct containing options for generating the diff summary.
- /// Returns a `Result` containing a DashMap with the generated summaries if successful, or a boxed `dyn std::error::Error` if an error occurs.
+ /// Returns a Result containing a DashMap with the generated summaries if successful, or a boxed dyn std::error::Error if an error occurs.
- match Repository::open(Entry) {
- Ok(Repository) => {
+ let Repository = Arc::new(Repository::open(Entry)?);
+
- let mut Tag: Vec<_> = Name.iter().filter_map(|Tag| Tag).collect();
+ let mut Date: Vec<(String, DateTime<FixedOffset>)> = Name
+ .par_iter()
+ .filter_map(|Tag| {
+ Tag.and_then(|Tag| {
+ Repository
+ .revparse_single(&Tag)
+ .ok()
+ .and_then(|Commit| Commit.peel_to_commit().ok())
+ .map(|Commit| {
+ (
+ Tag.to_string(),
+ DateTime::from_timestamp(Commit.time().seconds(), 0)
+ .unwrap()
+ .fixed_offset(),
+ )
+ let mut Date: Vec<(String, DateTime<FixedOffset>)> = Name
+ .iter()
+ .filter_map(|Tag| {
+ Tag.and_then(|Tag| {
+ Repository
+ .revparse_single(&Tag)
+ .ok()
+ .and_then(|Commit| Commit.peel_to_commit().ok())
+ .map(|Commit| {
+ (
+ Tag.to_string(),
+ DateTime::from_timestamp(Commit.time().seconds(), 0)
+ .unwrap()
+ .fixed_offset(),
+ )
+ })
+ })
+ })
+ })
+ .collect();
+ })
+ .collect();
+
+ Date.par_sort_by(|A, B| B.1.cmp(&A.1));
+ Date.sort_by(|A, B| A.1.cmp(&B.1)); // Sort in descending order (newest first)
- Tag.sort();
- Tag.dedup();
+ let Tag: Vec<String> = Date.into_iter().map(|(Tag, _)| Tag).collect();
+ let (Approval, mut Receipt) = mpsc::unbounded_channel();
+ let Approval = Arc::new(Mutex::new(Approval));
+
+ let mut Queue = FuturesUnordered::new();
+
- Insert::Fn(
- &Summary,
- crate::Fn::Summary::Difference::Fn(&Repository, &First, &Last, Option)?,
- format!("🗣️ Summary from first commit to last commit"),
- )
+ let RepositoryClone = Repository.clone();
+ let ApprovalClone = Approval.clone();
+ let OptionClone = Option.clone();
+
+ Queue.push(tokio::spawn(async move {
+ let Summary =
+ crate::Fn::Summary::Difference::Fn(&RepositoryClone, &First, &Last, &OptionClone)?;
+ ApprovalClone
+ .lock()
+ .await
+ .send(("🗣️ Summary from first commit to last commit".to_string(), Summary))?;
+ Ok::<(), Box<dyn std::error::Error + Send + Sync>>(())
+ }));
+ let Tag: Vec<String> = Date.into_iter().map(|(Tag, _)| Tag).collect();
- let Start = Window[0];
- let End = Window[1];
-
- Insert::Fn(
- &Summary,
+ let Start = &Window[0];
+ let End = &Window[1];
- crate::Fn::Summary::Difference::Fn(&Repository, Start, End, Option)?,
- format!("🗣️ Summary from {} to {}", Start, End),
- );
+ let Start = Window[0].clone();
+ let End = Window[1].clone();
+ let RepositoryClone = Repository.clone();
+ let ApprovalClone = Approval.clone();
+ let OptionClone = Option.clone();
+
+ Queue.push(tokio::spawn(async move {
+ let Summary = crate::Fn::Summary::Difference::Fn(
+ &RepositoryClone,
+ &Start,
+ &End,
+ &OptionClone,
+ )?;
+ ApprovalClone
+ .lock()
+ .await
+ .send((format!("🗣️ Summary from {} to {}", Start, End), Summary))?;
+ Ok::<(), Box<dyn std::error::Error + Send + Sync>>(())
+ }));
- Insert::Fn(
- &Summary,
- crate::Fn::Summary::Difference::Fn(&Repository, &First, Latest, Option)?,
- format!("🗣️ Summary from first commit to {}", Latest),
- );
-
- Insert::Fn(
- &Summary,
- crate::Fn::Summary::Difference::Fn(&Repository, Latest, &Last, Option)?,
- format!("🗣️ Summary from {} to last commit", Latest),
- );
+ let Latest = Latest.clone();
+ let RepositoryClone = Repository.clone();
+ let ApprovalClone = Approval.clone();
+ let OptionClone = Option.clone();
+
+ Queue.push(tokio::spawn(async move {
+ let Summary = crate::Fn::Summary::Difference::Fn(
+ &RepositoryClone,
+ &First,
+ &Latest,
+ &OptionClone,
+ )?;
+ ApprovalClone
+ .lock()
+ .await
+ .send((format!("🗣️ Summary from first commit to {}", Latest), Summary))?;
+ Ok::<(), Box<dyn std::error::Error + Send + Sync>>(())
+ }));
+
+ let RepositoryClone = Repository.clone();
+ let ApprovalClone = Approval.clone();
+ let OptionClone = Option.clone();
+
+ Queue.push(tokio::spawn(async move {
+ let Summary = crate::Fn::Summary::Difference::Fn(
+ &RepositoryClone,
+ &Latest,
+ &Last,
+ &OptionClone,
+ )?;
+ ApprovalClone
+ .lock()
+ .await
+ .send((format!("🗣️ Summary from {} to last commit", Latest), Summary))?;
+ Ok::<(), Box<dyn std::error::Error + Send + Sync>>(())
+ }));
+
+ drop(Approval);
+
+ while let Some(Result) = Queue.next().await {
+ if let Err(E) = Result {
+ eprintln!("Task error: {}", E);
+ continue;
- Err(_Error) => {
- println!("Cannot Repository: {}", _Error);
- return Err(_Error.into());
+ if let Err(E) = Result.unwrap() {
+ eprintln!("Inner task error: {}", E);
+ }
+
+ while let Some((Message, Difference)) = Receipt.recv().await {
+ Insert::Fn(&Summary, Difference, Message);
+ crate::Fn::Summary::Difference::Fn(&Repository, &Start, &End, Option)?,
+ use chrono::{DateTime, FixedOffset};
+ use futures::stream::{FuturesUnordered, StreamExt};
+ use rayon::prelude::*;
+ use std::sync::Arc;
+ use tokio::sync::{mpsc, Mutex};
🗣️ Summary from first commit to Summary/v0.1.1 in .
diff --git a/.cargo/Config.toml b/.cargo/Config.toml
Expand Down

0 comments on commit a400fcf

Please sign in to comment.