add "random" endpoint that just redirects you to a random node. #1

Merged
erika merged 2 commits from :random into main 2024-03-31 18:23:12 +00:00
Showing only changes of commit b2b1a6bab6 - Show all commits

View file

@ -60,14 +60,14 @@ fn handle_next(hash) {
fn handle_random() {
let db_path = "members.db"
use conn <- sqlight.with_connection(db_path)
let next =
let random =
nebkor marked this conversation as resolved Outdated
Outdated
Review

can we rename next to random?

can we rename `next` to `random`?
sqlight.query(
"select next from ring order by random() limit 1",
on: conn,
expecting: dynamic.decode1(Row, dynamic.element(0, dynamic.string)),
)
case next {
Ok([Row(next_link)]) -> wisp.redirect(next_link)
case random {
nebkor marked this conversation as resolved Outdated
Outdated
Review

And here

And here
Ok([Row(random_link)]) -> wisp.redirect(random_link)
nebkor marked this conversation as resolved Outdated
Outdated
Review

and here

and here
_ -> wisp.not_found()
}
}