Skip to content

Commit

Permalink
add rating debug
Browse files Browse the repository at this point in the history
  • Loading branch information
vsilent committed Sep 3, 2023
1 parent 374d906 commit 521cafc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 27 deletions.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
# stacker
# stacker


Run db migration
```
sqlx migrate run
```

Down migration

```
sqlx migrate revert
```


Add rating

```
curl -vX POST 'http://localhost:8000/rating' -d '{"obj_id": 111, "category": "application", "comment":"some comment", "rate": 10}' --header 'Content-Type: application/json'
```
7 changes: 1 addition & 6 deletions src/routes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
mod get_stack;
mod health_checks;
// mod add_stack;
// mod deploy;
mod rating;

// pub use get_stack::*;
pub use health_checks::*;
// pub use add_stack::*;
// crate::routes::
pub use rating::*;
17 changes: 14 additions & 3 deletions src/routes/rating.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
use actix_web::HttpResponse;
use actix_web::{web, HttpResponse};
use serde::{Deserialize, Serialize};


// workflow
// add, update, list, get(user_id), ACL,
// ACL - access to func for a user
// ACL - access to objects for a user

pub async fn rating() -> HttpResponse {
unimplemented!()
#[derive(Serialize, Deserialize, Debug)]
pub struct RatingForm {
pub obj_id: u32, // product external id
pub category: String, // rating of product | rating of service etc
pub comment: String, // always linked to a product
pub rate: u32, //
}

pub async fn rating(form: web::Json<RatingForm>) -> HttpResponse {
println!("{:?}", form);
HttpResponse::Ok().finish()
}
19 changes: 2 additions & 17 deletions src/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,9 @@ pub fn run(listener: TcpListener, db_pool: PgPool) -> Result<Server, std::io::Er
)
.service(
web::resource("/rating")
.route(web::get()
.to(crate::routes::rating)),
.route(web::get().to(crate::routes::rating))
.route(web::post().to(crate::routes::rating)),
)
// .service(
// web::resource("/stack/{id}")
// .route(web::get()
// .to(crate::routes::get_stack)),
// )
// .service(
// web::resource("/stack")
// .route(web::post()
// .to(crate::routes::validate_stack)),
// )
// .service(
// web::resource("/deploy")
// .route(web::post()
// .to(crate::routes::deploy)),
// )
.app_data(db_pool.clone())
})
.listen(listener)?
Expand Down

0 comments on commit 521cafc

Please sign in to comment.