Skip to content

Commit

Permalink
Merge pull request #5 from slyons/dev/missing_file_size
Browse files Browse the repository at this point in the history
Adding missing file size to Post resource
  • Loading branch information
slyons authored Sep 6, 2024
2 parents f3e7e82 + bbc323f commit 791b63c
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## v0.6.2 (2024-09-06)

### Fix

- **models_rs**: adding the missing field fileSize to the post resource

### Refactor

- **tokens_rs**: adding conditional compilation for an import

## v0.6.1 (2024-09-06)

### Fix
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions szurubooru-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## v0.6.2 (2024-09-06)

### Fix

- **models_rs**: adding the missing field fileSize to the post resource

### Refactor

- **tokens_rs**: adding conditional compilation for an import

## v0.6.1 (2024-09-06)

### Fix
Expand Down
2 changes: 1 addition & 1 deletion szurubooru-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "szurubooru-client"
version = "0.6.1"
version = "0.6.2"
edition = "2021"
authors = ["Scott Lyons <[email protected]>"]
description = "A wrapper around the Szurubooru API, including type-safe Query and Sort tokens"
Expand Down
69 changes: 67 additions & 2 deletions szurubooru-client/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ pub struct PostResource {
#[serde(rename = "checksumMD5")]
/// The MD5 file checksum
pub checksum_md5: Option<String>,
/// The size of the file
pub file_size: Option<u64>,
/// The original width of the post content.
pub canvas_width: Option<u32>,
/// The original height of the post content.
Expand Down Expand Up @@ -484,7 +486,7 @@ pub struct PostResource {
/// useful for `<video>` tags for instance
pub mime_type: Option<String>,
/// All the comments on the post
pub comment: Option<Vec<CommentResource>>,
pub comments: Option<Vec<CommentResource>>,
/// The pools in which the post is a member
pub pools: Option<Vec<PoolResource>>,
}
Expand Down Expand Up @@ -1657,7 +1659,9 @@ impl AroundPostResult {

#[cfg(test)]
mod tests {
use crate::models::{GlobalInfo, GlobalInfoConfig, SnapshotResource, TagCategoryResource};
use crate::models::{
GlobalInfo, GlobalInfoConfig, PostResource, SnapshotResource, TagCategoryResource,
};
use chrono::Datelike;

#[test]
Expand Down Expand Up @@ -1729,6 +1733,67 @@ mod tests {
assert_eq!(tag_cat.name, Some("default".to_string()));
}

#[test]
fn test_parse_post() {
let input_str = r#"
{
"id": 1,
"version": 1,
"creationTime": "2024-08-10T20:00:36.540774Z",
"lastEditTime": null,
"safety": "safe",
"source": "https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Maine_Coon_cat_by_Tomitheos.JPG/225px-Maine_Coon_cat_by_Tomitheos.JPG",
"type": "image",
"mimeType": "image/jpeg",
"checksum": "1c0a8a30909183f4340081ae7c3b9b0d76fcfa8a",
"checksumMD5": "4e5915ba12d3e31ea63e8d1a4cda8ec7",
"fileSize": 21555,
"canvasWidth": 225,
"canvasHeight": 480,
"contentUrl": "data/posts/1_eec1e16c588816e7.jpg",
"thumbnailUrl": "data/generated-thumbnails/1_eec1e16c588816e7.jpg",
"flags": [],
"tags": [
{
"names": [
"cat"
],
"category": "default",
"usages": 1
},
{
"names": [
"maine_coon"
],
"category": "default",
"usages": 1
}
],
"relations": [],
"user": {
"name": "integration_user",
"avatarUrl": "https://gravatar.com/avatar/6ab25d2babacc114ca560bff7c264d08?d=retro&s=300"
},
"score": 0,
"ownScore": 0,
"ownFavorite": false,
"tagCount": 2,
"favoriteCount": 0,
"commentCount": 0,
"noteCount": 0,
"relationCount": 0,
"featureCount": 0,
"lastFeatureTime": null,
"favoritedBy": [],
"hasCustomThumbnail": false,
"notes": [],
"comments": [],
"pools": []
}
"#;
serde_json::from_str::<PostResource>(input_str).expect("Could not parse post resource");
}

#[test]
fn test_parse_snapshot() {
let input_str = r#"
Expand Down

0 comments on commit 791b63c

Please sign in to comment.