We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d99b538 commit 6dcd4deCopy full SHA for 6dcd4de
migration/src/lib.rs
@@ -19,4 +19,4 @@ impl MigratorTrait for Migrator {
19
// inject-above (do not remove this comment)
20
]
21
}
22
-}
+}
migration/src/m20250423_224330_posts.rs
@@ -7,18 +7,18 @@ pub struct Migration;
7
#[async_trait::async_trait]
8
impl MigrationTrait for Migration {
9
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
10
- create_table(m, "posts",
+ create_table(
11
+ m,
12
+ "posts",
13
&[
-
- ("id", ColType::PkAuto),
14
15
- ("title", ColType::String),
16
- ("content", ColType::Text),
17
- ("views", ColType::Integer),
+ ("id", ColType::PkAuto),
+ ("title", ColType::String),
+ ("content", ColType::Text),
+ ("views", ColType::Integer),
18
],
- &[
- ]
- ).await
+ &[],
+ )
+ .await
23
24
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
migration/src/m20250430_022410_post_views.rs
@@ -7,21 +7,20 @@ pub struct Migration;
- create_table(m, "post_views",
+ "post_views",
- ("ip_address", ColType::String),
- ("user_agent", ColType::TextNull),
- ("location", ColType::StringNull),
- ("referer", ColType::StringNull),
- ("device_type", ColType::StringNull),
+ ("ip_address", ColType::String),
+ ("user_agent", ColType::TextNull),
+ ("location", ColType::StringNull),
+ ("referer", ColType::StringNull),
+ ("device_type", ColType::StringNull),
- ("posts", ""),
+ &[("posts", "")],
25
26
27
src/controllers/mod.rs
@@ -1,3 +1,3 @@
1
pub mod auth;
2
3
-pub mod posts;
+pub mod posts;
src/controllers/posts.rs
@@ -10,7 +10,7 @@ use axum::{
extract::Query,
http::{HeaderMap, StatusCode},
};
-use axum_client_ip::{InsecureClientIp, SecureClientIp};
+use axum_client_ip::InsecureClientIp;
use chrono::{Duration, Utc};
use loco_rs::prelude::*;
use serde::Deserialize;
@@ -130,7 +130,7 @@ pub async fn increase_views(
130
let now = Utc::now();
131
let cutoff = now - Duration::hours(6);
132
133
- let mut post = posts::Entity::find_by_id(id)
+ let post = posts::Entity::find_by_id(id)
134
.one(&_ctx.db)
135
.await?
136
.ok_or(Error::NotFound)?;
src/fixtures/users.yaml
@@ -1,17 +1,9 @@
---
- id: 1
pid: 11111111-1111-1111-1111-111111111111
4
- email: user1@example.com
+ email: miguel@gmail.com
5
password: "$argon2id$v=19$m=19456,t=2,p=1$ETQBx4rTgNAZhSaeYZKOZg$eYTdH26CRT6nUJtacLDEboP0li6xUwUF/q5nSlQ8uuc"
6
api_key: lo-95ec80d7-cb60-4b70-9b4b-9ef74cb88758
- name: user1
- created_at: "2023-11-12T12:34:56.789Z"
- updated_at: "2023-11-12T12:34:56.789Z"
-- id: 2
- pid: 22222222-2222-2222-2222-222222222222
- email: user2@example.com
- password: "$argon2id$v=19$m=19456,t=2,p=1$ETQBx4rTgNAZhSaeYZKOZg$eYTdH26CRT6nUJtacLDEboP0li6xUwUF/q5nSlQ8uuc"
- api_key: lo-153561ca-fa84-4e1b-813a-c62526d0a77e
- name: user2
+ name: Miguer
created_at: "2023-11-12T12:34:56.789Z"
updated_at: "2023-11-12T12:34:56.789Z"
src/models/mod.rs
@@ -1,4 +1,4 @@
pub mod _entities;
-pub mod users;
pub mod post_views;
+pub mod users;
tests/models/post_views.rs
@@ -1,5 +1,5 @@
-use miguer_api::app::App;
use loco_rs::testing::prelude::*;
+use miguer_api::app::App;
use serial_test::serial;
macro_rules! configure_insta {
tests/models/posts.rs
tests/requests/posts.rs
#[tokio::test]
@@ -14,4 +14,3 @@ async fn can_get_posts() {
})
.await;
0 commit comments