Skip to content

Commit 4bd8ed9

Browse files
authored
Merge pull request #1408 from nebocco/feature/remove_api
Remove Deprecated API
2 parents 5c99f31 + c3320fe commit 4bd8ed9

File tree

6 files changed

+19
-97
lines changed

6 files changed

+19
-97
lines changed

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,28 @@
11
use super::{
2-
RankingRequest, RankingRequestFormat, RankingResponseFormat, RankingSelector, UserRankRequest,
2+
RankingRequest, RankingRequestFormat, RankingResponse, RankingSelector, UserRankRequest,
33
UserRankResponse, UserRankSelector,
44
};
55

66
use actix_web::{error, web, Result};
77
use async_trait::async_trait;
8-
use serde::Serialize;
98
use sql_client::{rated_point_sum::RatedPointSumClient, PgPool};
109

11-
#[deprecated(
12-
note = "this special Response type is deprecated and will be replaced with super::RankingResponse"
13-
)]
14-
#[derive(Debug, Serialize)]
15-
pub(crate) struct RPSRankingResponse {
16-
user_id: String,
17-
count: i64,
18-
point_sum: i64,
19-
}
20-
21-
impl RankingResponseFormat for RPSRankingResponse {}
22-
2310
pub(crate) struct RatedPointSumRanking;
2411

2512
#[async_trait(?Send)]
2613
impl RankingSelector for RatedPointSumRanking {
2714
type Request = RankingRequest;
28-
type Response = RPSRankingResponse;
15+
type Response = RankingResponse;
2916
async fn fetch(pool: web::Data<PgPool>, query: Self::Request) -> Result<Vec<Self::Response>> {
3017
let ranking = pool
3118
.load_rated_point_sum_in_range(query.range())
3219
.await
3320
.map_err(error::ErrorInternalServerError)?;
3421
Ok(ranking
3522
.into_iter()
36-
.map(|entry| RPSRankingResponse {
23+
.map(|entry| RankingResponse {
3724
user_id: entry.user_id,
3825
count: entry.point_sum,
39-
point_sum: entry.point_sum,
4026
})
4127
.collect())
4228
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use crate::server::{
1111
user_info::get_user_info,
1212
user_submissions::get_user_submission_count,
1313
user_submissions::{
14-
get_recent_submissions, get_user_submissions, get_user_submissions_from_time,
15-
get_users_time_submissions,
14+
get_recent_submissions, get_user_submissions_from_time, get_users_time_submissions,
1615
},
1716
};
1817

@@ -43,7 +42,6 @@ pub fn config_services(cfg: &mut web::ServiceConfig) {
4342
.service(endpoint::internal_api::progress_reset::delete_progress_reset_item)
4443
.service(
4544
web::scope("/atcoder-api")
46-
.service(web::resource("/results").route(web::get().to(get_user_submissions)))
4745
.service(
4846
web::scope("/v2")
4947
.service(web::resource("/user_info").route(web::get().to(get_user_info))),

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::server::MakeCors;
2-
use actix_web::http::header::CACHE_CONTROL;
32
use actix_web::{error, web, HttpRequest, HttpResponse, Result};
43
use serde::{Deserialize, Serialize};
54
use sql_client::submission_client::{SubmissionClient, SubmissionRequest};
@@ -14,23 +13,6 @@ pub(crate) struct GetUserSubmissionQuery {
1413
to_second: Option<i64>,
1514
}
1615

17-
pub(crate) async fn get_user_submissions(
18-
_request: HttpRequest,
19-
pool: web::Data<PgPool>,
20-
query: web::Query<GetUserSubmissionQuery>,
21-
) -> Result<HttpResponse> {
22-
let user_id = &query.user;
23-
let submissions = pool
24-
.get_submissions(SubmissionRequest::UserAll { user_id })
25-
.await
26-
.map_err(error::ErrorInternalServerError)?;
27-
let response = HttpResponse::Ok()
28-
.make_cors()
29-
.insert_header((CACHE_CONTROL, "max-age=300"))
30-
.json(&submissions);
31-
Ok(response)
32-
}
33-
3416
pub(crate) async fn get_user_submissions_from_time(
3517
_request: HttpRequest,
3618
pool: web::Data<PgPool>,

atcoder-problems-backend/tests/test_server_e2e_rated_point_sum_ranking.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ async fn test_rated_point_sum_ranking() {
3434
assert_eq!(
3535
response,
3636
json!([
37-
{"user_id":"u2","point_sum":2,"count":2},
38-
{"user_id":"u1","point_sum":1,"count":1},
39-
{"user_id":"u3","point_sum":1,"count":1}
37+
{"user_id":"u2","count":2},
38+
{"user_id":"u1","count":1},
39+
{"user_id":"u3","count":1}
4040
])
4141
);
4242

@@ -48,8 +48,8 @@ async fn test_rated_point_sum_ranking() {
4848
assert_eq!(
4949
response,
5050
json!([
51-
{"user_id":"u1","point_sum":1,"count":1},
52-
{"user_id":"u3","point_sum":1,"count":1}
51+
{"user_id":"u1","count":1},
52+
{"user_id":"u3","count":1}
5353
])
5454
);
5555

@@ -61,7 +61,7 @@ async fn test_rated_point_sum_ranking() {
6161
assert_eq!(
6262
response,
6363
json!([
64-
{"user_id":"u2","point_sum":2,"count":2}
64+
{"user_id":"u2","count":2}
6565
])
6666
);
6767

atcoder-problems-backend/tests/test_server_e2e_submissions.rs

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use actix_web::{http::StatusCode, test, App};
2-
use atcoder_problems_backend::server::config_services;
32
use serde_json::Value;
43
use sql_client::models::Submission;
54
use sql_client::PgPool;
@@ -36,35 +35,6 @@ async fn prepare_data_set(conn: &PgPool) {
3635
.unwrap();
3736
}
3837

39-
#[actix_web::test]
40-
async fn test_user_submissions() {
41-
let pg_pool = utils::initialize_and_connect_to_test_sql().await;
42-
prepare_data_set(&pg_pool).await;
43-
44-
let app = test::init_service(
45-
App::new()
46-
.app_data(actix_web::web::Data::new(pg_pool))
47-
.configure(config_services),
48-
)
49-
.await;
50-
51-
let request = test::TestRequest::get()
52-
.uri("/atcoder-api/results?user=u1")
53-
.to_request();
54-
let submissions: Vec<Submission> = test::call_and_read_body_json(&app, request).await;
55-
56-
assert_eq!(submissions.len(), 5);
57-
assert!(submissions.iter().all(|s| s.user_id == "u1"));
58-
59-
let response = test::TestRequest::get()
60-
.uri("/atcoder-api/results?user=u2")
61-
.to_request();
62-
let submissions: Vec<Submission> = test::call_and_read_body_json(&app, response).await;
63-
64-
assert_eq!(submissions.len(), 5);
65-
assert!(submissions.iter().all(|s| s.user_id == "u2"));
66-
}
67-
6838
#[actix_web::test]
6939
async fn test_user_submissions_fromtime() {
7040
let pg_pool = utils::initialize_and_connect_to_test_sql().await;
@@ -186,7 +156,7 @@ async fn test_invalid_path() {
186156
assert_eq!(response.status(), StatusCode::NOT_FOUND);
187157

188158
let response = test::TestRequest::get()
189-
.uri("/atcoder-api/results")
159+
.uri("/atcoder-api/v3/user/submissions")
190160
.send_request(&app)
191161
.await;
192162

@@ -256,7 +226,7 @@ async fn test_cors() {
256226
);
257227

258228
let response = test::TestRequest::get()
259-
.uri("/atcoder-api/results?user=u1")
229+
.uri("/atcoder-api/v3/user/submissions?user=u1&from_second=0")
260230
.send_request(&app)
261231
.await;
262232

doc/api.md

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,15 @@ https://kenkoooo.com/atcoder/atcoder-api/v3/ac_ranking?from=0&to=10
3636
https://kenkoooo.com/atcoder/atcoder-api/v3/user/ac_rank?user=kenkoooo
3737
```
3838

39-
Deprecated ~~https://kenkoooo.com/atcoder/resources/ac.json~~ This old API will be removed soon. You can see more detail about the plan ([#989](https://github.com/kenkoooo/AtCoderProblems/issues/989)).
40-
4139
### Rated Point Sum
4240

4341
#### Example
4442

45-
4643
```
4744
https://kenkoooo.com/atcoder/atcoder-api/v3/rated_point_sum_ranking?from=0&to=10
4845
https://kenkoooo.com/atcoder/atcoder-api/v3/user/rated_point_sum_rank?user=kenkoooo
4946
```
5047

51-
Deprecated ~~https://kenkoooo.com/atcoder/resources/sums.json~~ This old API will be removed soon. You can see more detail about the plan ([#1031](https://github.com/kenkoooo/AtCoderProblems/issues/1031)).
52-
5348
### Longest Streak (JST) Count
5449

5550
#### Example
@@ -59,8 +54,6 @@ https://kenkoooo.com/atcoder/atcoder-api/v3/streak_ranking?from=0&to=10
5954
https://kenkoooo.com/atcoder/atcoder-api/v3/user/streak_rank?user=kenkoooo
6055
```
6156

62-
Deprecated ~~https://kenkoooo.com/atcoder/resources/streaks.json~~ This old API will be removed soon. You can see more detail about the plan ([#981](https://github.com/kenkoooo/AtCoderProblems/issues/981)).
63-
6457
### Language List
6558

6659
#### Example
@@ -78,8 +71,6 @@ https://kenkoooo.com/atcoder/atcoder-api/v3/language_ranking?from=0&to=10&langua
7871
https://kenkoooo.com/atcoder/atcoder-api/v3/user/language_rank?user=kenkoooo
7972
```
8073

81-
Deprecated ~~https://kenkoooo.com/atcoder/resources/lang.json~~ This old API will be removed soon. You can see more detail about the plan ([#1002](https://github.com/kenkoooo/AtCoderProblems/issues/1002)).
82-
8374
## Submission API
8475

8576
### User Submissions
@@ -99,16 +90,6 @@ https://kenkoooo.com/atcoder/atcoder-api/v3/user/submissions?user={user_id}&from
9990
https://kenkoooo.com/atcoder/atcoder-api/v3/user/submissions?user=chokudai&from_second=1560046356
10091
```
10192

102-
### [Deprecated] ~~User Submissions~~
103-
104-
This API is deprecated. Please use `/v3/user/submissions` instead. You can see more detail about the deprecation plan ([#961](https://github.com/kenkoooo/AtCoderProblems/issues/961)).
105-
106-
#### Interface
107-
108-
```
109-
https://kenkoooo.com/atcoder/atcoder-api/results?user={user_id}
110-
```
111-
11293
### Submissions at the time
11394

11495
#### Interface
@@ -123,8 +104,13 @@ https://kenkoooo.com/atcoder/atcoder-api/v3/from/{unix_time_second}
123104

124105
## Deprecated
125106

126-
- `/v2/user_info`
127-
- `/atcoder/atcoder-api/info/*`
107+
- `/atcoder-api/v2/user_info`
108+
- `/atcoder-api/info/*`
109+
- `/atcoder-api/results`
110+
- `/resources/ac.json`
111+
- `/resources/lang.json`
112+
- `/resources/streaks.json`
113+
- `/resources/sums.json`
128114

129115
## Datasets
130116

0 commit comments

Comments
 (0)