You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let spendables = rows.iter().map(Spendable::from).collect();
66
+
67
+
let total_count = list_spendable_total_count(&pool, channel_id).await?;
68
+
69
+
// fast ceil for total_pages
70
+
let total_pages = if total_count == 0{
71
+
1
72
+
}else{
73
+
1 + ((total_count - 1) / limit asu64)
74
+
};
75
+
76
+
let pagination = Pagination{
77
+
total_pages,
78
+
page: skip / limit asu64,
79
+
};
56
80
57
-
Ok(rows.iter().map(Spendable::from).collect())
81
+
Ok((spendables, pagination))
58
82
}
59
83
60
-
staticUPDATE_SPENDABLE_STATEMENT:&str = "WITH inserted_spendable AS (INSERT INTO spendable(spender, channel_id, total, still_on_create2) VALUES($1, $2, $3, $4) ON CONFLICT ON CONSTRAINT spendable_pkey DO UPDATE SET total = $3, still_on_create2 = $4 WHERE spendable.spender = $1 AND spendable.channel_id = $2 RETURNING *) SELECT inserted_spendable.*, channels.leader, channels.follower, channels.guardian, channels.token, channels.nonce FROM inserted_spendable INNER JOIN channels ON inserted_spendable.channel_id = channels.id";
84
+
staticUPDATE_SPENDABLE_STATEMENT:&str = "WITH inserted_spendable AS (INSERT INTO spendable(spender, channel_id, total, still_on_create2, created) VALUES($1, $2, $3, $4, $5) ON CONFLICT ON CONSTRAINT spendable_pkey DO UPDATE SET total = $3, still_on_create2 = $4 WHERE spendable.spender = $1 AND spendable.channel_id = $2 RETURNING *) SELECT inserted_spendable.*, channels.leader, channels.follower, channels.guardian, channels.token, channels.nonce FROM inserted_spendable INNER JOIN channels ON inserted_spendable.channel_id = channels.id";
61
85
62
86
// Updates spendable entry deposit or inserts a new spendable entry if it doesn't exist
0 commit comments