Skip to content

Commit

Permalink
Fix patch bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Nov 21, 2023
1 parent fe9dedb commit dc85343
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
30 changes: 15 additions & 15 deletions src/todomvc/item.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ select
from
items
where
items.user_id = $1
items.user_id = ?1
group by
completed
order by
Expand Down Expand Up @@ -77,7 +77,7 @@ pub fn insert_item(
insert into items
(content, user_id)
values
($1, $2)
(?1, ?2)
returning
id
"
Expand Down Expand Up @@ -118,9 +118,9 @@ select
from
items
where
id = $1
id = ?1
and
user_id = $2
user_id = ?2
"

let assert Ok(rows) =
Expand Down Expand Up @@ -153,9 +153,9 @@ select
from
items
where
user_id = $1
user_id = ?1
and
completed = $2
completed = ?2
order by
inserted_at asc
"
Expand Down Expand Up @@ -183,7 +183,7 @@ select
from
items
where
user_id = $1
user_id = ?1
order by
inserted_at asc
"
Expand All @@ -207,9 +207,9 @@ pub fn delete_item(item_id: Int, user_id: Int, db: sqlight.Connection) -> Nil {
delete from
items
where
id = $1
id = ?1
and
user_id = $2
user_id = ?2
"
let assert Ok(_) =
sqlight.query(
Expand All @@ -234,11 +234,11 @@ pub fn update_item(
update
items
set
content = $3
content = ?3
where
id = $1
id = ?1
and
user_id = $2
user_id = ?2
returning
id,
completed,
Expand All @@ -265,7 +265,7 @@ pub fn delete_completed(user_id: Int, db: sqlight.Connection) -> Nil {
delete from
items
where
user_id = $1
user_id = ?1
and
completed = true
"
Expand All @@ -288,9 +288,9 @@ update
set
completed = not completed
where
id = $1
id = ?1
and
user_id = $2
user_id = ?2
returning
id,
completed,
Expand Down
3 changes: 0 additions & 3 deletions src/todomvc/router.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import todomvc/templates/completed_cleared as completed_cleared_template
import todomvc/item.{type Category, Item}
import todomvc/web.{type Context}
import wisp.{type Request, type Response}
import gleam/io

pub fn handle_request(req: Request, ctx: Context) -> Response {
let req = wisp.method_override(req)
Expand All @@ -21,8 +20,6 @@ pub fn handle_request(req: Request, ctx: Context) -> Response {
use ctx <- web.authenticate(req, ctx)
use <- wisp.serve_static(req, under: "/", from: ctx.static_path)

io.debug(req)

case wisp.path_segments(req) {
[] -> home(ctx, item.All)
["active"] -> home(ctx, item.Active)
Expand Down

0 comments on commit dc85343

Please sign in to comment.