Skip to content

Commit 47189a3

Browse files
committed
chore: fix formatting
1 parent 2b76d6f commit 47189a3

10 files changed

Lines changed: 148 additions & 100 deletions

File tree

src/app.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ pub async fn run(configuration: Configuration, api_version: &Version) -> Running
164164
configuration.clone(),
165165
user_profile_repository.clone(),
166166
authorization_service.clone(),
167-
))
168-
;
167+
));
169168

170169
// Build app container
171170

src/console/cronjobs/tracker_statistics_importer.rs

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -117,32 +117,35 @@ pub fn start(
117117
error!("Failed to send heartbeat from importer cronjob: {}", e);
118118
}
119119

120-
match weak_tracker_statistics_importer.upgrade() { Some(statistics_importer) => {
121-
let one_interval_ago = seconds_ago_utc(
122-
torrent_stats_update_interval
123-
.try_into()
124-
.expect("update interval should be a positive integer"),
125-
);
126-
let limit = 50;
127-
128-
debug!(
129-
"Importing torrents statistics not updated since {} limited to a maximum of {} torrents ...",
130-
one_interval_ago.to_string().yellow(),
131-
limit.to_string().yellow()
132-
);
133-
134-
match statistics_importer
135-
.import_torrents_statistics_not_updated_since(one_interval_ago, limit)
136-
.await
137-
{
138-
Ok(()) => {}
139-
Err(e) => error!("Failed to import statistics: {:?}", e),
120+
match weak_tracker_statistics_importer.upgrade() {
121+
Some(statistics_importer) => {
122+
let one_interval_ago = seconds_ago_utc(
123+
torrent_stats_update_interval
124+
.try_into()
125+
.expect("update interval should be a positive integer"),
126+
);
127+
let limit = 50;
128+
129+
debug!(
130+
"Importing torrents statistics not updated since {} limited to a maximum of {} torrents ...",
131+
one_interval_ago.to_string().yellow(),
132+
limit.to_string().yellow()
133+
);
134+
135+
match statistics_importer
136+
.import_torrents_statistics_not_updated_since(one_interval_ago, limit)
137+
.await
138+
{
139+
Ok(()) => {}
140+
Err(e) => error!("Failed to import statistics: {:?}", e),
141+
}
142+
143+
drop(statistics_importer);
140144
}
141-
142-
drop(statistics_importer);
143-
} _ => {
144-
break;
145-
}}
145+
_ => {
146+
break;
147+
}
148+
}
146149

147150
execution_interval.tick().await;
148151
}

src/databases/mysql.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,23 @@ impl Database for Mysql {
172172
Some(UsersSorting::UsernameZA) => "username DESC".to_string(),
173173
};
174174

175-
let (join_filters, where_filters) = filters.as_ref().map_or_else(|| (String::new(), String::new()), |filters| {
176-
let (mut join_filters_query, mut where_filters_query) = (String::new(), String::new());
177-
for filter in filters {
178-
match filter {
179-
UsersFilters::TorrentUploader => join_filters_query.push_str(
180-
"INNER JOIN torrust_torrents tt
175+
let (join_filters, where_filters) = filters.as_ref().map_or_else(
176+
|| (String::new(), String::new()),
177+
|filters| {
178+
let (mut join_filters_query, mut where_filters_query) = (String::new(), String::new());
179+
for filter in filters {
180+
match filter {
181+
UsersFilters::TorrentUploader => join_filters_query.push_str(
182+
"INNER JOIN torrust_torrents tt
181183
ON tu.user_id = tt.uploader_id ",
182-
),
183-
UsersFilters::EmailNotVerified => where_filters_query.push_str(" AND email_verified = false"),
184-
UsersFilters::EmailVerified => where_filters_query.push_str(" AND email_verified = true"),
184+
),
185+
UsersFilters::EmailNotVerified => where_filters_query.push_str(" AND email_verified = false"),
186+
UsersFilters::EmailVerified => where_filters_query.push_str(" AND email_verified = true"),
187+
}
185188
}
186-
}
187-
(join_filters_query, where_filters_query)
188-
});
189+
(join_filters_query, where_filters_query)
190+
},
191+
);
189192

190193
let mut query_string = format!(
191194
"SELECT

src/databases/sqlite.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,23 @@ impl Database for Sqlite {
173173
Some(UsersSorting::UsernameZA) => "username DESC".to_string(),
174174
};
175175

176-
let (join_filters, where_filters) = filters.as_ref().map_or_else(|| (String::new(), String::new()), |filters| {
177-
let (mut join_filters_query, mut where_filters_query) = (String::new(), String::new());
178-
for filter in filters {
179-
match filter {
180-
UsersFilters::TorrentUploader => join_filters_query.push_str(
181-
"INNER JOIN torrust_torrents tt
176+
let (join_filters, where_filters) = filters.as_ref().map_or_else(
177+
|| (String::new(), String::new()),
178+
|filters| {
179+
let (mut join_filters_query, mut where_filters_query) = (String::new(), String::new());
180+
for filter in filters {
181+
match filter {
182+
UsersFilters::TorrentUploader => join_filters_query.push_str(
183+
"INNER JOIN torrust_torrents tt
182184
ON tu.user_id = tt.uploader_id ",
183-
),
184-
UsersFilters::EmailNotVerified => where_filters_query.push_str(" AND email_verified = false"),
185-
UsersFilters::EmailVerified => where_filters_query.push_str(" AND email_verified = true"),
185+
),
186+
UsersFilters::EmailNotVerified => where_filters_query.push_str(" AND email_verified = false"),
187+
UsersFilters::EmailVerified => where_filters_query.push_str(" AND email_verified = true"),
188+
}
186189
}
187-
}
188-
(join_filters_query, where_filters_query)
189-
});
190+
(join_filters_query, where_filters_query)
191+
},
192+
);
190193

191194
let mut query_string = format!(
192195
"SELECT

src/services/settings.rs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,18 @@ impl Service {
8686
}
8787

8888
fn extract_public_settings(settings: &Settings) -> ConfigurationPublic {
89-
let email_on_signup = settings.registration.as_ref().map_or(EmailOnSignup::NotIncluded, |registration| {
90-
registration.email.as_ref().map_or(EmailOnSignup::NotIncluded, |email| {
91-
if email.required {
92-
EmailOnSignup::Required
93-
} else {
94-
EmailOnSignup::Optional
95-
}
96-
})
97-
});
89+
let email_on_signup = settings
90+
.registration
91+
.as_ref()
92+
.map_or(EmailOnSignup::NotIncluded, |registration| {
93+
registration.email.as_ref().map_or(EmailOnSignup::NotIncluded, |email| {
94+
if email.required {
95+
EmailOnSignup::Required
96+
} else {
97+
EmailOnSignup::Optional
98+
}
99+
})
100+
});
98101

99102
ConfigurationPublic {
100103
website_name: settings.website.name.clone(),
@@ -253,15 +256,18 @@ mod tests {
253256
let configuration = Configuration::default();
254257
let all_settings = configuration.get_all().await;
255258

256-
let email_on_signup = all_settings.registration.as_ref().map_or(EmailOnSignup::NotIncluded, |registration| {
257-
registration.email.as_ref().map_or(EmailOnSignup::NotIncluded, |email| {
258-
if email.required {
259-
EmailOnSignup::Required
260-
} else {
261-
EmailOnSignup::Optional
262-
}
263-
})
264-
});
259+
let email_on_signup = all_settings
260+
.registration
261+
.as_ref()
262+
.map_or(EmailOnSignup::NotIncluded, |registration| {
263+
registration.email.as_ref().map_or(EmailOnSignup::NotIncluded, |email| {
264+
if email.required {
265+
EmailOnSignup::Required
266+
} else {
267+
EmailOnSignup::Optional
268+
}
269+
})
270+
});
265271

266272
assert_eq!(
267273
extract_public_settings(&all_settings),

src/ui/proxy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn get_error_images() -> &'static ErrorImages {
3434
})
3535
}
3636

37-
#[must_use]
37+
#[must_use]
3838
pub fn map_error_to_image(error: &Error) -> Bytes {
3939
let images = get_error_images();
4040
match error {

src/web/api/client/v1/http.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,11 @@ impl Http {
263263
///
264264
/// Will return an error if there was an error while sending request,
265265
/// redirect loop was detected or redirect limit was exhausted.
266-
pub async fn delete_with_body<T: Serialize + ?Sized + Sync>(&self, path: &str, form: &T) -> Result<TextResponse, reqwest::Error> {
266+
pub async fn delete_with_body<T: Serialize + ?Sized + Sync>(
267+
&self,
268+
path: &str,
269+
form: &T,
270+
) -> Result<TextResponse, reqwest::Error> {
267271
let response = match &self.connection_info.token {
268272
Some(token) => {
269273
reqwest::Client::new()

tests/e2e/web/api/v1/contexts/tag/contract.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ async fn it_should_allow_admins_to_add_new_tags() {
7878

7979
let tag_name = random_tag_name();
8080

81-
let response = client
82-
.add_tag(AddTagForm {
83-
name: tag_name.clone(),
84-
})
85-
.await;
81+
let response = client.add_tag(AddTagForm { name: tag_name.clone() }).await;
8682

8783
assert_added_tag_response(&response, &tag_name);
8884
}
@@ -273,11 +269,7 @@ mod authorization {
273269

274270
let tag_name = random_tag_name();
275271

276-
let response = client
277-
.add_tag(AddTagForm {
278-
name: tag_name.clone(),
279-
})
280-
.await;
272+
let response = client.add_tag(AddTagForm { name: tag_name.clone() }).await;
281273

282274
assert_eq!(response.status, 200);
283275
}

0 commit comments

Comments
 (0)