-
-
Notifications
You must be signed in to change notification settings - Fork 889
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
implement language tags for site/community in db and api #2434
Conversation
c703d13
to
de90e5b
Compare
I think instead of |
28c4b01
to
f1388e0
Compare
This should be ready to merge. Still needs api tests (which require updated lemmy-js-client), and a lot of additional testing (during and after lemmy-ui implementation of this feature). Also need to test that db upgrades are working fine. |
Last commit is broken, adding the list of languages to CommunityView seems tricky. |
return Err(LemmyError::from_message("language_not_allowed")); | ||
} | ||
blocking(context.pool(), move |conn| { | ||
CommunityLanguage::update(conn, languages, community_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can delete the subset check above, and just make sure CommunityLanguage::update is doing the subset in SQL by reading from SiteLanguages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean as part of the insert statement? How would that work in sql?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I mean inside the CommunityLanguage::update(
fn, where it looks like you are already reading the site languages anyway. Looks like since users are providing any list of languages, you do have to read the site languages from sql, but can do a .retain
type thing in that function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but i cant move the check in here because of LemmyError in return value. Then i would also have to return LemmyError from Community::create(), which is incompatible with the trait.
171d714
to
ddbc7b6
Compare
8ae41fc
to
5aad293
Compare
crates/api_crud/src/post/create.rs
Outdated
Ok::<(Vec<LanguageId>, Vec<LanguageId>, LanguageId), LemmyError>(( | ||
LocalUserLanguage::read(conn, local_user_id)?, | ||
CommunityLanguage::read(conn, community_id)?, | ||
Language::undetermined(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still an issue, this intersect logic should be done in SQL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didnt finish addressing all the review comments yet, thats why they arent marked as resolved.
return Err(LemmyError::from_message("language_not_allowed")); | ||
} | ||
blocking(context.pool(), move |conn| { | ||
CommunityLanguage::update(conn, languages, community_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I mean inside the CommunityLanguage::update(
fn, where it looks like you are already reading the site languages anyway. Looks like since users are providing any list of languages, you do have to read the site languages from sql, but can do a .retain
type thing in that function.
670d201
to
aad0f16
Compare
Okay made all the requested changes, except for the one in EditCommunity which is not possible due to error types. |
e163855
to
b33ab7d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job, the main thing I was concerned about was the intersection logic being in SQL. Feel free to merge once you add the TODO.
.limit(1) | ||
.into_boxed(); | ||
site_language | ||
.filter(site_id.eq_any(subquery)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put a TODO here because this subquery is bad. This should go away once we add a site:local column.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
.filter(c::local) | ||
.filter(sl::language_id.is_null()) | ||
.select(cl::language_id) | ||
.get_results(conn)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, nice job.
.filter(ul::local_user_id.eq(local_user_id)) | ||
.filter(cl::community_id.eq(community_id)) | ||
.select(cl::language_id) | ||
.get_results::<LanguageId>(conn)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect. I think I need some way to get this info to the front end tho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this to GetCommunityView.
Once this is merged, I'll start on the front end for it. |
also, when making a new post and subset of user lang, community lang contains only one item, use that as post lang
540b062
to
a4e427e
Compare
Check all the commit messages for a list of changes.