Handle needs_unread on tag query. Move News to top of tag list
This commit is contained in:
parent
79db94f67f
commit
834efc5c94
@ -8,6 +8,11 @@ SELECT
|
|||||||
FROM
|
FROM
|
||||||
post AS p
|
post AS p
|
||||||
JOIN feed AS f ON p.site = f.slug
|
JOIN feed AS f ON p.site = f.slug
|
||||||
|
WHERE
|
||||||
|
(
|
||||||
|
NOT $1
|
||||||
|
OR NOT is_read
|
||||||
|
)
|
||||||
GROUP BY
|
GROUP BY
|
||||||
1,
|
1,
|
||||||
2
|
2
|
||||||
|
|||||||
@ -244,8 +244,8 @@ impl QueryRoot {
|
|||||||
let nm = ctx.data_unchecked::<Notmuch>();
|
let nm = ctx.data_unchecked::<Notmuch>();
|
||||||
let pool = ctx.data_unchecked::<PgPool>();
|
let pool = ctx.data_unchecked::<PgPool>();
|
||||||
let needs_unread = ctx.look_ahead().field("unread").exists();
|
let needs_unread = ctx.look_ahead().field("unread").exists();
|
||||||
let mut tags = nm::tags(nm, needs_unread)?;
|
let mut tags = newsreader::tags(pool, needs_unread).await?;
|
||||||
tags.append(&mut newsreader::tags(pool, needs_unread).await?);
|
tags.append(&mut nm::tags(nm, needs_unread)?);
|
||||||
Ok(tags)
|
Ok(tags)
|
||||||
}
|
}
|
||||||
async fn thread<'ctx>(&self, ctx: &Context<'ctx>, thread_id: String) -> Result<Thread, Error> {
|
async fn thread<'ctx>(&self, ctx: &Context<'ctx>, thread_id: String) -> Result<Thread, Error> {
|
||||||
|
|||||||
@ -92,7 +92,9 @@ pub async fn search(
|
|||||||
|
|
||||||
pub async fn tags(pool: &PgPool, needs_unread: bool) -> Result<Vec<Tag>, ServerError> {
|
pub async fn tags(pool: &PgPool, needs_unread: bool) -> Result<Vec<Tag>, ServerError> {
|
||||||
// TODO: write separate query for needs_unread.
|
// TODO: write separate query for needs_unread.
|
||||||
let tags = sqlx::query_file!("sql/tags.sql").fetch_all(pool).await?;
|
let tags = sqlx::query_file!("sql/tags.sql", needs_unread)
|
||||||
|
.fetch_all(pool)
|
||||||
|
.await?;
|
||||||
let tags = tags
|
let tags = tags
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|tag| {
|
.map(|tag| {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user