diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 24a52ce4..2d46bb36 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: ratings base: core22 -version: '1.6' +version: '1.8' license: GPL-3.0 summary: Ubuntu App Ratings Service description: | diff --git a/src/app/interfaces/authentication.rs b/src/app/interfaces/authentication.rs index 459ea548..fab1436e 100644 --- a/src/app/interfaces/authentication.rs +++ b/src/app/interfaces/authentication.rs @@ -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, Status> { let app_ctx = req.extensions().get::().unwrap().clone(); diff --git a/src/app/interfaces/middleware.rs b/src/app/interfaces/middleware.rs index 9ead934f..df28f25a 100644 --- a/src/app/interfaces/middleware.rs +++ b/src/app/interfaces/middleware.rs @@ -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; diff --git a/src/features/app/infrastructure.rs b/src/features/app/infrastructure.rs index 41834750..76c74dff 100644 --- a/src/features/app/infrastructure.rs +++ b/src/features/app/infrastructure.rs @@ -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, diff --git a/src/features/app/interface.rs b/src/features/app/interface.rs index cb4da56c..2c568f1d 100644 --- a/src/features/app/interface.rs +++ b/src/features/app/interface.rs @@ -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] diff --git a/src/features/app/use_cases.rs b/src/features/app/use_cases.rs index 3c29e9a9..49233beb 100644 --- a/src/features/app/use_cases.rs +++ b/src/features/app/use_cases.rs @@ -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 { let votes = get_votes_by_snap_id(app_ctx, &snap_id) .await diff --git a/src/features/chart/entities.rs b/src/features/chart/entities.rs index 7bb9d345..12a4c5bd 100644 --- a/src/features/chart/entities.rs +++ b/src/features/chart/entities.rs @@ -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, diff --git a/src/features/chart/infrastructure.rs b/src/features/chart/infrastructure.rs index 6bd4988a..4ed0f07b 100644 --- a/src/features/chart/infrastructure.rs +++ b/src/features/chart/infrastructure.rs @@ -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, diff --git a/src/features/chart/interface.rs b/src/features/chart/interface.rs index fbbf2af9..61b5ddf1 100644 --- a/src/features/chart/interface.rs +++ b/src/features/chart/interface.rs @@ -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] diff --git a/src/features/chart/use_cases.rs b/src/features/chart/use_cases.rs index 4358ffd3..e94e2caa 100644 --- a/src/features/chart/use_cases.rs +++ b/src/features/chart/use_cases.rs @@ -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 { let votes = get_votes_summary_by_timeframe(app_ctx, timeframe) diff --git a/src/features/user/interface.rs b/src/features/user/interface.rs index b2962fd4..d9469569 100644 --- a/src/features/user/interface.rs +++ b/src/features/user/interface.rs @@ -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] diff --git a/src/features/user/use_cases.rs b/src/features/user/use_cases.rs index 4605fc6f..a3fc457e 100644 --- a/src/features/user/use_cases.rs +++ b/src/features/user/use_cases.rs @@ -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 {