We have an urgent performance problem to get finished. The SQL changes are fine, but it seems the Lemmy test code in Rust is defective. This test is failing after we fixed a faulty stored procedure function in PostgreSQL: https://github.com/LemmyNet/lemmy/blob/13a866aeb0c24f20ed18ab40c0ea5616ef910676/crates/db_schema/src/aggregates/site_aggregates.rs#L157

The underlying Rust code needs to be enhanced to query the SQL table with SELECT site_aggregates WHERE site_id = 1, hard-coded 1 is fine, that is always the local site in Lemmy.

Can you please detail all the code changes so that the read method takes an integer parameter for site_id field?

https://github.com/LemmyNet/lemmy/blob/13a866aeb0c24f20ed18ab40c0ea5616ef910676/crates/db_schema/src/aggregates/site_aggregates.rs#L10C7-L10C7

Right now the query has no WHERE clause, pulling the first row it gets. Thank you.

Looking at the diesel docs it should be site_aggregates::table.filter(site_aggregates::site_id.eq(1)).load(…

https://diesel.rs/ see the third example

RoundSparrow
creator
banned
link
fedilink
5
edit-2
1Y
site_aggregates::table.filter(site_aggregates::site_id.eq(1)).first::<Self>(conn).await
                                                       ^^ `schema::site_aggregates::columns::site_id` is not an iterator

Try site_aggregates::dsl::site_id.eq(1).

RoundSparrow
creator
banned
link
fedilink
51Y

second reply.

Going over both error messages again, found this: https://stackoverflow.com/questions/70389667/rust-diesel-method-filter-exists-for-schema-table-but-its-trait-bounds-were-n

seems adding:

use diesel::prelude::*;

Might be helping. This compiles now:

    site_aggregates::table.filter(site_aggregates::site_id.eq(1)).first::<Self>(conn).await

RoundSparrow
creator
banned
link
fedilink
31Y
   --> crates/db_schema/src/aggregates/site_aggregates.rs:12:35
    |
12  |     site_aggregates::dsl::site_id.eq(1).first::<Self>(conn).await
    |                                   ^^ `schema::site_aggregates::columns::site_id` is not an iterator
    |
   ::: crates/db_schema/src/schema.rs:817:9
    |
817 |         site_id -> Int4,
    |         -------
    |         |
    |         method `eq` not found for this struct
    |         doesn't satisfy `_: Iterator`
    |
    = note: the following trait bounds were not satisfied:
            `schema::site_aggregates::columns::site_id: Iterator`
            which is required by `&mut schema::site_aggregates::columns::site_id: Iterator`
Rust Programming
!rust@lemmy.ml
    • 0 users online
    • 2 users / day
    • 2 users / week
    • 2 users / month
    • 74 users / 6 months
    • 1 subscriber
    • 258 Posts
    • 707 Comments
    • Modlog