-
Notifications
You must be signed in to change notification settings - Fork 1
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
23 changed files
with
243 additions
and
490 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,23 +1,25 @@ | ||
use crate::common::database::repositories::*; | ||
use crate::services::*; | ||
use crate::types::*; | ||
use std::sync::Arc; | ||
|
||
pub struct GetNewTreesHandler { | ||
db: Arc<dyn DatabaseInterface>, | ||
loader: Arc<TreeListLoader>, | ||
trees: Arc<TreeRepository>, | ||
} | ||
|
||
impl GetNewTreesHandler { | ||
pub async fn handle(&self, count: u64, skip: u64) -> Result<TreeList> { | ||
let trees = self.db.get_new_trees(count, skip).await?; | ||
let trees = self.trees.get_recently_created(count, skip).await?; | ||
self.loader.load(&trees).await | ||
} | ||
} | ||
|
||
impl Locatable for GetNewTreesHandler { | ||
fn create(locator: &Locator) -> Result<Self> { | ||
let db = locator.get::<PreferredDatabase>()?.driver(); | ||
let loader = locator.get::<TreeListLoader>()?; | ||
Ok(Self { db, loader }) | ||
Ok(Self { | ||
loader: locator.get::<TreeListLoader>()?, | ||
trees: locator.get::<TreeRepository>()?, | ||
}) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,23 +1,25 @@ | ||
use crate::common::database::repositories::*; | ||
use crate::services::*; | ||
use crate::types::*; | ||
use std::sync::Arc; | ||
|
||
pub struct GetTopCircumferenceHandler { | ||
db: Arc<dyn DatabaseInterface>, | ||
loader: Arc<TreeListLoader>, | ||
trees: Arc<TreeRepository>, | ||
} | ||
|
||
impl GetTopCircumferenceHandler { | ||
pub async fn handle(&self) -> Result<TreeList> { | ||
let trees = self.db.get_top_circumference(100).await?; | ||
let trees = self.trees.get_top_circumference(100).await?; | ||
self.loader.load(&trees).await | ||
} | ||
} | ||
|
||
impl Locatable for GetTopCircumferenceHandler { | ||
fn create(locator: &Locator) -> Result<Self> { | ||
let db = locator.get::<PreferredDatabase>()?.driver(); | ||
let loader = locator.get::<TreeListLoader>()?; | ||
Ok(Self { db, loader }) | ||
Ok(Self { | ||
loader: locator.get::<TreeListLoader>()?, | ||
trees: locator.get::<TreeRepository>()?, | ||
}) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,23 +1,25 @@ | ||
use crate::common::database::repositories::*; | ||
use crate::services::*; | ||
use crate::types::*; | ||
use std::sync::Arc; | ||
|
||
pub struct GetTopDiameterHandler { | ||
db: Arc<dyn DatabaseInterface>, | ||
loader: Arc<TreeListLoader>, | ||
trees: Arc<TreeRepository>, | ||
} | ||
|
||
impl GetTopDiameterHandler { | ||
pub async fn handle(&self) -> Result<TreeList> { | ||
let trees = self.db.get_top_diameter(100).await?; | ||
let trees = self.trees.get_top_diameter(100).await?; | ||
self.loader.load(&trees).await | ||
} | ||
} | ||
|
||
impl Locatable for GetTopDiameterHandler { | ||
fn create(locator: &Locator) -> Result<Self> { | ||
let db = locator.get::<PreferredDatabase>()?.driver(); | ||
let loader = locator.get::<TreeListLoader>()?; | ||
Ok(Self { db, loader }) | ||
Ok(Self { | ||
loader: locator.get::<TreeListLoader>()?, | ||
trees: locator.get::<TreeRepository>()?, | ||
}) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,23 +1,25 @@ | ||
use crate::common::database::repositories::*; | ||
use crate::services::*; | ||
use crate::types::*; | ||
use std::sync::Arc; | ||
|
||
pub struct GetTopHeightHandler { | ||
db: Arc<dyn DatabaseInterface>, | ||
loader: Arc<TreeListLoader>, | ||
trees: Arc<TreeRepository>, | ||
} | ||
|
||
impl GetTopHeightHandler { | ||
pub async fn handle(&self) -> Result<TreeList> { | ||
let trees = self.db.get_top_height(100).await?; | ||
let trees = self.trees.get_top_height(100).await?; | ||
self.loader.load(&trees).await | ||
} | ||
} | ||
|
||
impl Locatable for GetTopHeightHandler { | ||
fn create(locator: &Locator) -> Result<Self> { | ||
let db = locator.get::<PreferredDatabase>()?.driver(); | ||
let loader = locator.get::<TreeListLoader>()?; | ||
Ok(Self { db, loader }) | ||
Ok(Self { | ||
loader: locator.get::<TreeListLoader>()?, | ||
trees: locator.get::<TreeRepository>()?, | ||
}) | ||
} | ||
} |
Oops, something went wrong.