forked from AbleOS/holey-bytes
fixing user posts not being displayed
This commit is contained in:
parent
4856533b22
commit
b030b1eeb7
|
@ -786,8 +786,29 @@ mod db {
|
|||
login: "INSERT OR REPLACE INTO session (id, username, expiration) VALUES(?, ?, ?)",
|
||||
logout: "DELETE FROM session WHERE id = ?",
|
||||
get_session: "SELECT username, expiration FROM session WHERE id = ?",
|
||||
get_user_posts: "SELECT author, name, timestamp, code FROM post WHERE author = ?
|
||||
ORDER BY timestamp DESC",
|
||||
get_user_posts: "SELECT author, name, timestamp, code, (
|
||||
WITH RECURSIVE roots(name, author, code) AS (
|
||||
SELECT name, author, code FROM post WHERE name = outher.name AND author = outher.author
|
||||
UNION
|
||||
SELECT post.name, post.author, post.code FROM
|
||||
post JOIN import ON post.name = import.from_name
|
||||
AND post.author = import.from_author
|
||||
JOIN roots ON import.to_name = roots.name
|
||||
AND import.to_author = roots.author
|
||||
) SELECT (count(*) - 1) FROM roots
|
||||
) AS imports, (
|
||||
WITH RECURSIVE roots(name, author, code) AS (
|
||||
SELECT name, author, code FROM post WHERE name = outher.name AND author = outher.author
|
||||
UNION
|
||||
SELECT post.name, post.author, post.code FROM post
|
||||
JOIN import ON post.name = import.from_name
|
||||
AND post.author = import.from_author
|
||||
JOIN roots ON import.to_name = roots.name
|
||||
AND import.to_author = roots.author
|
||||
) SELECT count(*) FROM roots
|
||||
JOIN run ON roots.name = run.code_name
|
||||
AND roots.author = run.code_author
|
||||
) AS runs FROM post as outher WHERE author = ? ORDER BY timestamp DESC",
|
||||
// TODO: we might want to cache the recursive queries
|
||||
get_pots_before: "SELECT author, name, timestamp, code, (
|
||||
WITH RECURSIVE roots(name, author, code) AS (
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
use {
|
||||
alloc::{string::String, vec::Vec},
|
||||
core::ffi::CStr,
|
||||
hblang::{
|
||||
son::{hbvm::HbvmBackend, Codegen, CodegenCtx},
|
||||
ty::Module,
|
||||
|
@ -98,8 +99,15 @@ unsafe fn compile_and_run(mut fuel: usize) {
|
|||
break;
|
||||
}
|
||||
Ok(hbvm::VmRunOk::Ecall) => {
|
||||
let unknown = ct.vm.read_reg(2).0;
|
||||
log::error!("unknown ecall: {unknown}")
|
||||
let kind = ct.vm.read_reg(2).0;
|
||||
match kind {
|
||||
0 => {
|
||||
let str = ct.vm.read_reg(3).0;
|
||||
let str = unsafe { CStr::from_ptr(str as _) };
|
||||
log::error!("{}", str.to_str().unwrap());
|
||||
}
|
||||
unknown => log::error!("unknown ecall: {unknown}"),
|
||||
}
|
||||
}
|
||||
Ok(hbvm::VmRunOk::Timer) => {
|
||||
fuel -= 1;
|
||||
|
|
Loading…
Reference in a new issue