Skip to content

Commit 4096088

Browse files
committed
fix: made Query structs public
1 parent d5ae7a6 commit 4096088

File tree

12 files changed

+76
-74
lines changed

12 files changed

+76
-74
lines changed

atcoder-problems-backend/src/server/auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl GitHubAuthentication {
8080
}
8181

8282
#[derive(Deserialize)]
83-
struct Query {
83+
pub(crate) struct Query {
8484
code: String,
8585
redirect_to: Option<String>,
8686
}

atcoder-problems-backend/src/server/internal_user.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use sql_client::internal::user_manager::UserManager;
55
use actix_web::{error, web, HttpRequest, HttpResponse, Result};
66

77
#[derive(Deserialize)]
8-
struct Query {
8+
pub(crate) struct Query {
99
atcoder_user_id: String,
1010
}
1111

atcoder-problems-backend/src/server/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ where
3030
App::new()
3131
.app_data(web::Data::new(app_data.clone()))
3232
.wrap(actix_web::middleware::Logger::default())
33-
.configure(services::config_services)
33+
.configure(services::config_services::<A>)
3434
})
3535
.bind((host, port))?
3636
.run()

atcoder-problems-backend/src/server/problem_list.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub(crate) async fn get_own_lists<A: Authentication + Clone + Send + Sync + 'sta
2020
}
2121

2222
#[derive(Deserialize)]
23-
struct GetListQuery {
23+
pub(crate) struct GetListQuery {
2424
list_id: String,
2525
}
2626

@@ -41,7 +41,7 @@ pub(crate) async fn get_single_list<A: Authentication + Clone + Send + Sync + 's
4141
}
4242

4343
#[derive(Deserialize)]
44-
struct CreateListQuery {
44+
pub(crate) struct CreateListQuery {
4545
list_name: String,
4646
}
4747

@@ -62,7 +62,7 @@ pub(crate) async fn create_list<A: Authentication + Clone + Send + Sync + 'stati
6262
}
6363

6464
#[derive(Deserialize)]
65-
struct DeleteListQuery {
65+
pub(crate) struct DeleteListQuery {
6666
internal_list_id: String,
6767
}
6868

@@ -81,7 +81,7 @@ pub(crate) async fn delete_list<A: Authentication + Clone + Send + Sync + 'stati
8181
}
8282

8383
#[derive(Deserialize)]
84-
struct UpdateListQuery {
84+
pub(crate) struct UpdateListQuery {
8585
internal_list_id: String,
8686
name: String,
8787
}
@@ -101,7 +101,7 @@ pub(crate) async fn update_list<A: Authentication + Clone + Send + Sync + 'stati
101101
}
102102

103103
#[derive(Deserialize)]
104-
struct AddItemQuery {
104+
pub(crate) struct AddItemQuery {
105105
internal_list_id: String,
106106
problem_id: String,
107107
}
@@ -121,7 +121,7 @@ pub(crate) async fn add_item<A: Authentication + Clone + Send + Sync + 'static>(
121121
}
122122

123123
#[derive(Deserialize)]
124-
struct UpdateItemQuery {
124+
pub(crate) struct UpdateItemQuery {
125125
internal_list_id: String,
126126
problem_id: String,
127127
memo: String,
@@ -142,7 +142,7 @@ pub(crate) async fn update_item<A: Authentication + Clone + Send + Sync + 'stati
142142
}
143143

144144
#[derive(Deserialize)]
145-
struct DeleteItemQuery {
145+
pub(crate) struct DeleteItemQuery {
146146
internal_list_id: String,
147147
problem_id: String,
148148
}

atcoder-problems-backend/src/server/progress_reset.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) async fn get_progress_reset_list<A: Authentication + Clone + Send + S
1616
}
1717

1818
#[derive(Deserialize)]
19-
struct AddItemQuery {
19+
pub(crate) struct AddItemQuery {
2020
problem_id: String,
2121
reset_epoch_second: i64,
2222
}
@@ -38,7 +38,7 @@ pub(crate) async fn add_progress_reset_item<A: Authentication + Clone + Send + S
3838
}
3939

4040
#[derive(Deserialize)]
41-
struct DeleteItemQuery {
41+
pub(crate) struct DeleteItemQuery {
4242
problem_id: String,
4343
}
4444

atcoder-problems-backend/src/server/ranking/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::ops::Range;
1010
use async_trait::async_trait;
1111

1212
#[derive(Deserialize)]
13-
struct UserRankRequest {
13+
pub(crate) struct UserRankRequest {
1414
user: String,
1515
}
1616

@@ -21,7 +21,7 @@ pub(crate) struct UserRankResponse {
2121
}
2222

2323
#[derive(Deserialize)]
24-
struct RankingRequest {
24+
pub(crate) struct RankingRequest {
2525
from: usize,
2626
to: usize,
2727
}
@@ -139,7 +139,7 @@ impl<A: Sync + Send + Clone + 'static> UserRankSelector<A> for AcRanking {
139139
}
140140

141141
#[derive(Deserialize)]
142-
struct LanguageQuery {
142+
pub(crate) struct LanguageQuery {
143143
from: usize,
144144
to: usize,
145145
language: String,
@@ -172,7 +172,7 @@ pub(crate) async fn get_language_ranking<A>(
172172
}
173173

174174
#[derive(Debug, Deserialize)]
175-
struct UsersLanguageQuery {
175+
pub(crate) struct UsersLanguageQuery {
176176
user: String,
177177
}
178178

atcoder-problems-backend/src/server/rated_point_sum_ranking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use sql_client::rated_point_sum::RatedPointSumClient;
66
const MAX_RANKING_RANGE_LENGTH: usize = 1000;
77

88
#[derive(Debug, Deserialize)]
9-
struct Query {
9+
pub(crate) struct Query {
1010
from: usize,
1111
to: usize,
1212
}
Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use actix_web::web;
1+
use actix_web::{web, HttpResponse};
22

33
use crate::server::{
44
internal_user,
@@ -8,7 +8,7 @@ use crate::server::{
88
delete_progress_reset_item,
99
},
1010
user_submissions::get_user_submission_count,
11-
auth::get_token,
11+
auth::{Authentication, get_token},
1212
language_count::get_language_list,
1313
problem_list::{
1414
add_item, create_list, delete_item, delete_list, get_own_lists, get_single_list, update_item, update_list,
@@ -21,8 +21,8 @@ use crate::server::{
2121
get_users_time_submissions,
2222
},
2323
ranking::{
24-
self, get_ac_ranking, get_language_ranking, get_streak_ranking, get_users_ac_rank,
25-
get_users_language_rank, get_users_rated_point_sum_rank, get_users_streak_rank,
24+
RankingSelector, UserRankSelector, StreakRanking, AcRanking, RatedPointSumRanking,
25+
get_language_ranking, get_users_language_rank,
2626
},
2727
virtual_contest::{
2828
create_contest, update_contest, update_items, get_single_contest,
@@ -31,76 +31,76 @@ use crate::server::{
3131
}
3232
};
3333

34-
pub(crate) fn config_services(cfg: &mut web::ServiceConfig) {
34+
pub(crate) fn config_services<A: Authentication + Clone + Send + Sync + 'static>(cfg: &mut web::ServiceConfig) {
3535
log::info!("Configuring routes...");
3636
cfg.service(
3737
web::scope("/internal-api")
38-
.service(web::resource("/authorize").route(web::get().to(get_token)))
38+
.service(web::resource("/authorize").route(web::get().to(get_token::<A>)))
3939
.service(
4040
web::scope("/list")
41-
.service(web::resource("/my").route(web::get().to(get_own_lists)))
42-
.service(web::resource("/get/{list_id}").route(web::get().to(get_single_list)))
43-
.service(web::resource("/create").route(web::post().to(create_list)))
44-
.service(web::resource("/delete").route(web::post().to(delete_list)))
45-
.service(web::resource("/update").route(web::post().to(update_list)))
41+
.service(web::resource("/my").route(web::get().to(get_own_lists::<A>)))
42+
.service(web::resource("/get/{list_id}").route(web::get().to(get_single_list::<A>)))
43+
.service(web::resource("/create").route(web::post().to(create_list::<A>)))
44+
.service(web::resource("/delete").route(web::post().to(delete_list::<A>)))
45+
.service(web::resource("/update").route(web::post().to(update_list::<A>)))
4646
.service(
4747
web::scope("/item")
48-
.service(web::resource("/add").route(web::post().to(add_item)))
49-
.service(web::resource("/update").route(web::post().to(update_item)))
50-
.service(web::resource("/delete").route(web::post().to(delete_item)))
48+
.service(web::resource("/add").route(web::post().to(add_item::<A>)))
49+
.service(web::resource("/update").route(web::post().to(update_item::<A>)))
50+
.service(web::resource("/delete").route(web::post().to(delete_item::<A>)))
5151
)
5252
)
5353
.service(
5454
web::scope("/contest")
55-
.service(web::resource("/create").route(web::post().to(create_contest)))
56-
.service(web::resource("/update").route(web::post().to(update_contest)))
57-
.service(web::resource("/item/update").route(web::post().to(update_items)))
58-
.service(web::resource("/get/{contest_id}").route(web::get().to(get_single_contest)))
59-
.service(web::resource("/join").route(web::post().to(join_contest)))
60-
.service(web::resource("/leave").route(web::post().to(leave_contest)))
61-
.service(web::resource("/my").route(web::get().to(get_my_contests)))
62-
.service(web::resource("/joined").route(web::get().to(get_participated)))
63-
.service(web::resource("/recent").route(web::get().to(get_recent_contests)))
55+
.service(web::resource("/create").route(web::post().to(create_contest::<A>)))
56+
.service(web::resource("/update").route(web::post().to(update_contest::<A>)))
57+
.service(web::resource("/item/update").route(web::post().to(update_items::<A>)))
58+
.service(web::resource("/get/{contest_id}").route(web::get().to(get_single_contest::<A>)))
59+
.service(web::resource("/join").route(web::post().to(join_contest::<A>)))
60+
.service(web::resource("/leave").route(web::post().to(leave_contest::<A>)))
61+
.service(web::resource("/my").route(web::get().to(get_my_contests::<A>)))
62+
.service(web::resource("/joined").route(web::get().to(get_participated::<A>)))
63+
.service(web::resource("/recent").route(web::get().to(get_recent_contests::<A>)))
6464
)
6565
.service(
6666
web::scope("/user")
67-
.service(web::resource("/get").route(web::get().to(internal_user::get)))
68-
.service(web::resource("/update").route(web::post().to(internal_user::update)))
67+
.service(web::resource("/get").route(web::get().to(internal_user::get::<A>)))
68+
.service(web::resource("/update").route(web::post().to(internal_user::update::<A>)))
6969
)
7070
.service(
7171
web::scope("/progress_reset")
72-
.service(web::resource("/list").route(web::get().to(get_progress_reset_list)))
73-
.service(web::resource("/add").route(web::post().to(add_progress_reset_item)))
74-
.service(web::resource("/delete").route(web::post().to(delete_progress_reset_item)))
72+
.service(web::resource("/list").route(web::get().to(get_progress_reset_list::<A>)))
73+
.service(web::resource("/add").route(web::post().to(add_progress_reset_item::<A>)))
74+
.service(web::resource("/delete").route(web::post().to(delete_progress_reset_item::<A>)))
7575
)
7676
).service(
7777
web::scope("/atcoder-api")
78-
.service(web::resource("/results").route(web::get().to(get_user_submissions)))
78+
.service(web::resource("/results").route(web::get().to(get_user_submissions::<A>)))
7979
.service(
8080
web::scope("/v2")
81-
.service(web::resource("/user_info").route(web::get().to(get_user_info)))
81+
.service(web::resource("/user_info").route(web::get().to(get_user_info::<A>)))
8282
)
8383
.service(
8484
web::scope("/v3")
85-
.service(web::resource("/user_info").route(web::get().to(get_user_info)))
86-
.service(web::resource("/rated_point_sum_ranking").route(web::get().to(get_rated_point_sum_ranking)))
87-
.service(web::resource("/ac_ranking").route(web::get().to(ranking::ranking(get_ac_ranking))))
88-
.service(web::resource("/streak_ranking").route(web::get().to(ranking::ranking(get_streak_ranking))))
89-
.service(web::resource("/language_ranking").route(web::get().to(get_language_ranking)))
90-
.service(web::resource("/from/{from}").route(web::get().to(get_time_submissions)))
91-
.service(web::resource("/recent").route(web::get().to(get_recent_submissions)))
92-
.service(web::resource("/users_and_time").route(web::get().to(get_users_time_submissions)))
85+
.service(web::resource("/user_info").route(web::get().to(get_user_info::<A>)))
86+
.service(web::resource("/rated_point_sum_ranking").route(web::get().to(get_rated_point_sum_ranking::<A>)))
87+
.service(web::resource("/ac_ranking").route(web::get().to(<AcRanking as RankingSelector<A>>::get_ranking)))
88+
.service(web::resource("/streak_ranking").route(web::get().to(<StreakRanking as RankingSelector<A>>::get_ranking)))
89+
.service(web::resource("/language_ranking").route(web::get().to(get_language_ranking::<A>)))
90+
.service(web::resource("/from/{from}").route(web::get().to(get_time_submissions::<A>)))
91+
.service(web::resource("/recent").route(web::get().to(get_recent_submissions::<A>)))
92+
.service(web::resource("/users_and_time").route(web::get().to(get_users_time_submissions::<A>)))
9393
.service(
9494
web::scope("/user")
95-
.service(web::resource("/submissions").route(web::get().to(get_user_submissions_from_time)))
96-
.service(web::resource("/submission_count").route(web::get().to(get_user_submission_count)))
97-
.service(web::resource("/ac_rank").route(web::get().to(ranking::user_rank(get_users_ac_rank))))
98-
.service(web::resource("/streak_rank").route(web::get().to(ranking::user_rank(get_users_streak_rank))))
99-
.service(web::resource("/language_rank").route(web::get().to(get_users_language_rank)))
100-
.service(web::resource("rated_point_sum_rank").route(web::get().to(ranking::user_rank(get_users_rated_point_sum_rank))))
95+
.service(web::resource("/submissions").route(web::get().to(get_user_submissions_from_time::<A>)))
96+
.service(web::resource("/submission_count").route(web::get().to(get_user_submission_count::<A>)))
97+
.service(web::resource("/ac_rank").route(web::get().to(<AcRanking as UserRankSelector<A>>::get_users_rank)))
98+
.service(web::resource("/streak_rank").route(web::get().to(<StreakRanking as UserRankSelector<A>>::get_users_rank)))
99+
.service(web::resource("/language_rank").route(web::get().to(get_users_language_rank::<A>)))
100+
.service(web::resource("rated_point_sum_rank").route(web::get().to(<RatedPointSumRanking as UserRankSelector<A>>::get_users_rank)))
101101
)
102-
.service(web::resource("language_list").route(web::get().to(get_language_list)))
102+
.service(web::resource("language_list").route(web::get().to(get_language_list::<A>)))
103103
)
104104
)
105-
.service(web::resource("/healthcheck").route(web::get().to(|_| async move { Ok("") })));
105+
.service(web::resource("/healthcheck").route(web::get().to(|| HttpResponse::Ok().finish())));
106106
}

atcoder-problems-backend/src/server/time_submissions.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
use crate::server::{AppData, CommonResponse};
2-
use sql_client::submission_client::{SubmissionClient, SubmissionRequest};
32
use actix_web::{error, web, HttpRequest, HttpResponse, Result};
3+
use serde::Deserialize;
4+
use sql_client::submission_client::{SubmissionClient, SubmissionRequest};
45

5-
struct Query {
6-
from: i64
6+
#[derive(Deserialize)]
7+
pub(crate) struct Query {
8+
from: i64,
79
}
810

911
pub(crate) async fn get_time_submissions<A>(
1012
request: HttpRequest,
1113
data: web::Data<AppData<A>>,
12-
query: web::Query<Query>
14+
query: web::Query<Query>,
1315
) -> Result<HttpResponse> {
1416
let from_epoch_second = query.from;
1517
let conn = data.pg_pool.clone();

atcoder-problems-backend/src/server/user_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use sql_client::accepted_count::AcceptedCountClient;
66
use sql_client::rated_point_sum::RatedPointSumClient;
77

88
#[derive(Deserialize)]
9-
struct Query {
9+
pub(crate) struct Query {
1010
user: String,
1111
}
1212
#[derive(Serialize)]

0 commit comments

Comments
 (0)