Skip to content

Commit

Permalink
style: import cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-hagemann committed Dec 7, 2023
1 parent 3952941 commit 3cc3073
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 57 deletions.
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ratings
base: core22
version: '1.6'
version: '1.8'
license: GPL-3.0
summary: Ubuntu App Ratings Service
description: |
Expand Down
3 changes: 1 addition & 2 deletions src/app/interfaces/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use http::header;
use tonic::{Request, Status};
use tracing::error;

use crate::app::context::AppContext;
use crate::app::RequestContext;
use crate::app::{context::AppContext, RequestContext};

pub fn authentication(req: Request<()>) -> Result<Request<()>, Status> {
let app_ctx = req.extensions().get::<AppContext>().unwrap().clone();
Expand Down
3 changes: 1 addition & 2 deletions src/app/interfaces/middleware.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::pin::Pin;

use hyper::service::Service;
use hyper::Body;
use hyper::{service::Service, Body};
use tonic::body::BoxBody;
use tower::Layer;

Expand Down
7 changes: 4 additions & 3 deletions src/features/app/infrastructure.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::{app::AppContext, features::common::entities::VoteSummary};
use crate::{
app::AppContext,
features::{app::errors::AppError, common::entities::VoteSummary},
};
use tracing::error;

use super::errors::AppError;

pub(crate) async fn get_votes_by_snap_id(
app_ctx: &AppContext,
snap_id: &str,
Expand Down
9 changes: 4 additions & 5 deletions src/features/app/interface.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use crate::app::AppContext;

use crate::features::pb::app::{GetRatingRequest, GetRatingResponse};
use crate::features::{
app::{service::AppService, use_cases},
pb::app::{app_server::App, GetRatingRequest, GetRatingResponse},
};
use tonic::{Request, Response, Status};

use crate::features::pb::app::app_server::App;

use super::{service::AppService, use_cases};

#[tonic::async_trait]
impl App for AppService {
#[tracing::instrument]
Expand Down
10 changes: 7 additions & 3 deletions src/features/app/use_cases.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use crate::{app::AppContext, features::common::entities::Rating};
use crate::{
app::AppContext,
features::{
app::{errors::AppError, infrastructure::get_votes_by_snap_id},
common::entities::Rating,
},
};
use tracing::error;

use super::{errors::AppError, infrastructure::get_votes_by_snap_id};

pub async fn get_rating(app_ctx: &AppContext, snap_id: String) -> Result<Rating, AppError> {
let votes = get_votes_by_snap_id(app_ctx, &snap_id)
.await
Expand Down
7 changes: 4 additions & 3 deletions src/features/chart/entities.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::features::{
common::entities::{calculate_band, Rating, VoteSummary},
pb::chart as pb,
};
use sqlx::FromRow;

use crate::features::common::entities::{calculate_band, Rating, VoteSummary};
use crate::features::pb::chart as pb;

pub struct Chart {
pub timeframe: pb::Timeframe,
pub chart_data: Vec<ChartData>,
Expand Down
9 changes: 4 additions & 5 deletions src/features/chart/infrastructure.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::app::AppContext;
use crate::features::common::entities::VoteSummary;
use crate::features::pb::chart::Timeframe;
use crate::{
app::AppContext,
features::{chart::errors::ChartError, common::entities::VoteSummary, pb::chart::Timeframe},
};
use tracing::error;

use super::errors::ChartError;

pub(crate) async fn get_votes_summary_by_timeframe(
app_ctx: &AppContext,
timeframe: Timeframe,
Expand Down
15 changes: 7 additions & 8 deletions src/features/chart/interface.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use crate::app::AppContext;

use crate::features::pb::chart::{GetChartRequest, GetChartResponse, Timeframe};
use crate::{
app::AppContext,
features::{
chart::{errors::ChartError, service::ChartService, use_cases},
pb::chart::{chart_server::Chart, GetChartRequest, GetChartResponse, Timeframe},
},
};
use tonic::{Request, Response, Status};

use crate::features::pb::chart::chart_server::Chart;

use super::errors::ChartError;
use super::{service::ChartService, use_cases};

#[tonic::async_trait]
impl Chart for ChartService {
#[tracing::instrument]
Expand Down
14 changes: 9 additions & 5 deletions src/features/chart/use_cases.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use super::{errors::ChartError, infrastructure::get_votes_summary_by_timeframe};
use crate::app::AppContext;
use crate::features::chart::entities::Chart;
use crate::features::pb::chart::Timeframe;
use crate::{
app::AppContext,
features::{
chart::{
entities::Chart, errors::ChartError, infrastructure::get_votes_summary_by_timeframe,
},
pb::chart::Timeframe,
},
};
use tracing::error;
// use super::{entities::Rating, errors::AppError, infrastructure::get_votes_by_snap_id};

pub async fn get_chart(app_ctx: &AppContext, timeframe: Timeframe) -> Result<Chart, ChartError> {
let votes = get_votes_summary_by_timeframe(app_ctx, timeframe)
Expand Down
23 changes: 10 additions & 13 deletions src/features/user/interface.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
use time::OffsetDateTime;

use tonic::{Request, Response, Status};

use crate::app::AppContext;
use crate::utils::jwt::Claims;

use super::entities::Vote;
use super::service::UserService;
use super::use_cases;

use crate::features::pb::user::{
AuthenticateRequest, AuthenticateResponse, GetSnapVotesRequest, GetSnapVotesResponse,
ListMyVotesRequest, ListMyVotesResponse, VoteRequest,
use crate::{
app::AppContext,
features::{
pb::user::{
user_server::User, AuthenticateRequest, AuthenticateResponse, GetSnapVotesRequest,
GetSnapVotesResponse, ListMyVotesRequest, ListMyVotesResponse, VoteRequest,
},
user::{entities::Vote, service::UserService, use_cases},
},
utils::jwt::Claims,
};

use crate::features::pb::user::user_server::User;

#[tonic::async_trait]
impl User for UserService {
#[tracing::instrument]
Expand Down
17 changes: 10 additions & 7 deletions src/features/user/use_cases.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use crate::app::AppContext;
use crate::features::user::infrastructure::{find_user_votes, save_vote_to_db};

use super::entities::{User, Vote};
use super::errors::UserError;
use super::infrastructure::{
create_or_seen_user, delete_user_by_client_hash, get_snap_votes_by_client_hash,
use crate::{
app::AppContext,
features::user::{
entities::{User, Vote},
errors::UserError,
infrastructure::{
create_or_seen_user, delete_user_by_client_hash, find_user_votes,
get_snap_votes_by_client_hash, save_vote_to_db,
},
},
};

pub async fn authenticate(app_ctx: &AppContext, id: &str) -> Result<User, UserError> {
Expand Down

0 comments on commit 3cc3073

Please sign in to comment.