-
-
Notifications
You must be signed in to change notification settings - Fork 880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CommunityLanguage::read() should return empty vec if all languages are selected #2495
Labels
Comments
The site_language and community_language tables do need to be populated, otherwise joins won't work. If they are equivalent tho, you could just turn them into empty vectors in code. |
I dont want to change anything about the way data is stored in the db, i just want to change how its returned from read() functions. In Rust it would look like this: pub fn read(conn: &mut PgConnection, for_site_id: SiteId) -> Result<Vec<LanguageId>, Error> {
use crate::schema::{language::dsl as language, site_language::dsl as site_language};
let site_languages = site_language::site_language
.filter(site_language::site_id.eq(for_site_id))
.select(site_language::language_id)
.load(conn)?;
let all_languages: Vec<LanguageId> = language::language.select(language::id).load(conn)?;
if site_languages.len() == all_languages.len() {
Ok(vec![])
} else {
Ok(site_languages)
}
} |
Nutomic
added a commit
that referenced
this issue
Oct 14, 2022
Nutomic
added a commit
that referenced
this issue
Oct 14, 2022
dessalines
pushed a commit
that referenced
this issue
Oct 14, 2022
Nutomic
added a commit
that referenced
this issue
Oct 17, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right now it just returns a list of all languages in that case, which means that the following command returns a total of 700 lines, listing all the languages.
curl -H 'Accept: application/activity+json' https://enterprise.lemmy.ml/c/main | jq .language
This doesnt make any sense, it should just return an empty vec if all languages are enabled in db, analogue to how CommunityLanguage::update() called with empty vec means that all languages should be enabled. The same goes for LocalUserLanguage::read and SiteLanguage::read.
However im not sure how to write a query which achieves this.
The text was updated successfully, but these errors were encountered: