Skip to content

Commit 9d9d4ff

Browse files
authored
Merge pull request #126 from rage/download-latest
Download latest
2 parents 0f2fb2d + d84270b commit 9d9d4ff

25 files changed

+517
-2292
lines changed

tmc-client/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ license = "MIT OR Apache-2.0"
99
tmc-langs-plugins = { path = "../tmc-langs-plugins" }
1010
tmc-langs-util = { path = "../tmc-langs-util" }
1111

12+
chrono = { version = "0.4", features = ["serde"] }
1213
dirs = "3"
1314
http = "0.2"
1415
lazy_static = "1"
@@ -17,7 +18,7 @@ oauth2 = { version = "4.0.0-alpha.3", features = ["reqwest"] }
1718
percent-encoding = "2"
1819
regex = "1"
1920
reqwest = { version = "0.11", default-features = false, features = ["blocking", "json", "rustls-tls", "multipart"] }
20-
schemars = "0.8"
21+
schemars = { version = "0.8", features = ["chrono"] }
2122
serde = { version = "1", features = ["derive"] }
2223
serde_json = "1"
2324
tempfile = "3"

tmc-client/src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type TokenError = oauth2::RequestTokenError<
1111
oauth2::StandardErrorResponse<oauth2::basic::BasicErrorResponseType>,
1212
>;
1313

14+
/// The main error type for tmc-client.
1415
#[derive(Debug, Error)]
1516
pub enum ClientError {
1617
// Arc

tmc-client/src/response.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Contains types which model the JSON responses from tmc-server
22
3+
use chrono::{DateTime, FixedOffset};
34
use lazy_static::lazy_static;
45
use regex::Regex;
56
use schemars::JsonSchema;
@@ -39,6 +40,7 @@ pub struct User {
3940
pub administrator: bool,
4041
}
4142

43+
/// Organization information.
4244
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
4345
pub struct Organization {
4446
pub name: String,
@@ -48,6 +50,7 @@ pub struct Organization {
4850
pub pinned: bool,
4951
}
5052

53+
/// Information for a course.
5154
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
5255
pub struct Course {
5356
pub id: usize,
@@ -61,6 +64,7 @@ pub struct Course {
6164
pub spyware_urls: Vec<String>,
6265
}
6366

67+
/// Data for a course.
6468
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
6569
pub struct CourseData {
6670
pub name: String,
@@ -69,7 +73,7 @@ pub struct CourseData {
6973
pub cache_version: Option<usize>,
7074
pub spreadsheet_key: Option<String>,
7175
pub hidden_if_registered_after: Option<String>,
72-
pub refreshed_at: Option<String>,
76+
pub refreshed_at: Option<DateTime<FixedOffset>>,
7377
pub locked_exercise_points_visible: bool,
7478
pub description: Option<String>,
7579
pub paste_visibility: Option<String>,
@@ -102,6 +106,7 @@ struct CourseDetailsInner {
102106
pub exercises: Vec<Exercise>,
103107
}
104108

109+
/// Details for a course.
105110
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
106111
#[serde(from = "CourseDetailsWrapper")]
107112
pub struct CourseDetails {
@@ -149,6 +154,7 @@ pub struct Exercise {
149154
pub solution_zip_url: Option<String>,
150155
}
151156

157+
/// Exercise for a course.
152158
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
153159
pub struct CourseExercise {
154160
pub id: usize,
@@ -195,9 +201,10 @@ pub struct AwardedPoint {
195201
user_id: usize,
196202
submission_id: usize,
197203
name: String,
198-
created_at: String,
204+
created_at: DateTime<FixedOffset>,
199205
}
200206

207+
/// Details for an exercise.
201208
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
202209
pub struct ExerciseDetails {
203210
pub course_name: String,
@@ -219,22 +226,23 @@ pub struct ExercisesDetails {
219226
pub checksum: String,
220227
}
221228

229+
/// Exercise submission.
222230
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
223231
pub struct Submission {
224232
pub id: usize,
225233
pub user_id: usize,
226234
pub pretest_error: Option<String>,
227-
pub created_at: String,
235+
pub created_at: DateTime<FixedOffset>,
228236
pub exercise_name: String,
229237
pub course_id: usize,
230238
pub processed: bool,
231239
pub all_tests_passed: bool,
232240
pub points: Option<String>,
233-
pub processing_tried_at: Option<String>,
234-
pub processing_began_at: Option<String>,
235-
pub processing_completed_at: Option<String>,
241+
pub processing_tried_at: Option<DateTime<FixedOffset>>,
242+
pub processing_began_at: Option<DateTime<FixedOffset>>,
243+
pub processing_completed_at: Option<DateTime<FixedOffset>>,
236244
pub times_sent_to_sandbox: usize,
237-
pub processing_attempts_started_at: String,
245+
pub processing_attempts_started_at: DateTime<FixedOffset>,
238246
pub params_json: Option<String>,
239247
pub requires_review: bool,
240248
pub requests_review: bool,
@@ -253,7 +261,7 @@ pub struct ExerciseSubmission {
253261
pub id: usize,
254262
pub user_id: usize,
255263
pub course_id: usize,
256-
pub created_at: String,
264+
pub created_at: DateTime<FixedOffset>,
257265
pub all_tests_passed: bool,
258266
pub points: Option<String>,
259267
pub submitted_zip_url: String,
@@ -263,6 +271,7 @@ pub struct ExerciseSubmission {
263271
pub requests_review: bool,
264272
}
265273

274+
/// Exercise submission.
266275
#[derive(Debug, Deserialize, Serialize, JsonSchema, Clone)]
267276
pub struct NewSubmission {
268277
pub show_submission_url: String,
@@ -291,6 +300,7 @@ pub enum SandboxStatus {
291300
ProcessingOnSandbox,
292301
}
293302

303+
/// Finished submission.
294304
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
295305
pub struct SubmissionFinished {
296306
pub api_version: usize,
@@ -328,6 +338,7 @@ pub enum SubmissionStatus {
328338
Hidden,
329339
}
330340

341+
/// Response to feedback.
331342
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
332343
pub struct SubmissionFeedbackResponse {
333344
pub api_version: usize,
@@ -419,6 +430,7 @@ impl<'de> Visitor<'de> for SubmissionFeedbackKindVisitor {
419430
}
420431
}
421432

433+
/// Code review.
422434
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
423435
pub struct Review {
424436
pub submission_id: String,
@@ -431,10 +443,11 @@ pub struct Review {
431443
pub points_not_awarded: Vec<String>,
432444
pub url: String,
433445
pub update_url: String,
434-
pub created_at: String,
446+
pub created_at: DateTime<FixedOffset>,
435447
pub updated_at: String,
436448
}
437449

450+
/// Updated exercises.
438451
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
439452
pub struct UpdateResult {
440453
pub created: Vec<Exercise>,

0 commit comments

Comments
 (0)