Skip to content

Commit 6dcd4de

Browse files
committed
formated
1 parent d99b538 commit 6dcd4de

File tree

10 files changed

+33
-43
lines changed

10 files changed

+33
-43
lines changed

migration/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ impl MigratorTrait for Migrator {
1919
// inject-above (do not remove this comment)
2020
]
2121
}
22-
}
22+
}

migration/src/m20250423_224330_posts.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ pub struct Migration;
77
#[async_trait::async_trait]
88
impl MigrationTrait for Migration {
99
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
10-
create_table(m, "posts",
10+
create_table(
11+
m,
12+
"posts",
1113
&[
12-
13-
("id", ColType::PkAuto),
14-
15-
("title", ColType::String),
16-
("content", ColType::Text),
17-
("views", ColType::Integer),
14+
("id", ColType::PkAuto),
15+
("title", ColType::String),
16+
("content", ColType::Text),
17+
("views", ColType::Integer),
1818
],
19-
&[
20-
]
21-
).await
19+
&[],
20+
)
21+
.await
2222
}
2323

2424
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {

migration/src/m20250430_022410_post_views.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@ pub struct Migration;
77
#[async_trait::async_trait]
88
impl MigrationTrait for Migration {
99
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
10-
create_table(m, "post_views",
10+
create_table(
11+
m,
12+
"post_views",
1113
&[
12-
13-
("id", ColType::PkAuto),
14-
15-
("ip_address", ColType::String),
16-
("user_agent", ColType::TextNull),
17-
("location", ColType::StringNull),
18-
("referer", ColType::StringNull),
19-
("device_type", ColType::StringNull),
14+
("id", ColType::PkAuto),
15+
("ip_address", ColType::String),
16+
("user_agent", ColType::TextNull),
17+
("location", ColType::StringNull),
18+
("referer", ColType::StringNull),
19+
("device_type", ColType::StringNull),
2020
],
21-
&[
22-
("posts", ""),
23-
]
24-
).await
21+
&[("posts", "")],
22+
)
23+
.await
2524
}
2625

2726
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {

src/controllers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pub mod auth;
22

3-
pub mod posts;
3+
pub mod posts;

src/controllers/posts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use axum::{
1010
extract::Query,
1111
http::{HeaderMap, StatusCode},
1212
};
13-
use axum_client_ip::{InsecureClientIp, SecureClientIp};
13+
use axum_client_ip::InsecureClientIp;
1414
use chrono::{Duration, Utc};
1515
use loco_rs::prelude::*;
1616
use serde::Deserialize;
@@ -130,7 +130,7 @@ pub async fn increase_views(
130130
let now = Utc::now();
131131
let cutoff = now - Duration::hours(6);
132132

133-
let mut post = posts::Entity::find_by_id(id)
133+
let post = posts::Entity::find_by_id(id)
134134
.one(&_ctx.db)
135135
.await?
136136
.ok_or(Error::NotFound)?;

src/fixtures/users.yaml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
---
22
- id: 1
33
pid: 11111111-1111-1111-1111-111111111111
4-
email: user1@example.com
4+
email: miguel@gmail.com
55
password: "$argon2id$v=19$m=19456,t=2,p=1$ETQBx4rTgNAZhSaeYZKOZg$eYTdH26CRT6nUJtacLDEboP0li6xUwUF/q5nSlQ8uuc"
66
api_key: lo-95ec80d7-cb60-4b70-9b4b-9ef74cb88758
7-
name: user1
8-
created_at: "2023-11-12T12:34:56.789Z"
9-
updated_at: "2023-11-12T12:34:56.789Z"
10-
- id: 2
11-
pid: 22222222-2222-2222-2222-222222222222
12-
email: user2@example.com
13-
password: "$argon2id$v=19$m=19456,t=2,p=1$ETQBx4rTgNAZhSaeYZKOZg$eYTdH26CRT6nUJtacLDEboP0li6xUwUF/q5nSlQ8uuc"
14-
api_key: lo-153561ca-fa84-4e1b-813a-c62526d0a77e
15-
name: user2
7+
name: Miguer
168
created_at: "2023-11-12T12:34:56.789Z"
179
updated_at: "2023-11-12T12:34:56.789Z"

src/models/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
pub mod _entities;
2-
pub mod users;
3-
pub mod posts;
42
pub mod post_views;
3+
pub mod posts;
4+
pub mod users;

tests/models/post_views.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use miguer_api::app::App;
21
use loco_rs::testing::prelude::*;
2+
use miguer_api::app::App;
33
use serial_test::serial;
44

55
macro_rules! configure_insta {

tests/models/posts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use miguer_api::app::App;
21
use loco_rs::testing::prelude::*;
2+
use miguer_api::app::App;
33
use serial_test::serial;
44

55
macro_rules! configure_insta {

tests/requests/posts.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use miguer_api::app::App;
21
use loco_rs::testing::prelude::*;
2+
use miguer_api::app::App;
33
use serial_test::serial;
44

55
#[tokio::test]
@@ -14,4 +14,3 @@ async fn can_get_posts() {
1414
})
1515
.await;
1616
}
17-

0 commit comments

Comments
 (0)