Skip to content
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

Use one struct per action table in view structs #5473

Open
5 tasks done
dullbananas opened this issue Mar 3, 2025 · 3 comments · May be fixed by #5482
Open
5 tasks done

Use one struct per action table in view structs #5473

dullbananas opened this issue Mar 3, 2025 · 3 comments · May be fixed by #5482
Milestone

Comments

@dullbananas
Copy link
Collaborator

Requirements

  • Is this a feature request? For questions or discussions use https://lemmy.ml/c/lemmy_support
  • Did you check to see if this issue already exists?
  • Is this only a feature request? Do not put multiple feature requests in one issue.
  • Is this a backend issue? Use the lemmy-ui repo for UI / frontend issues.
  • Do you agree to follow the rules in our Code of Conduct?

Is your proposal related to a problem?

The current flattened style causes a lot of duplication, which makes it hard to maintain consistency and add new actions to all views.

Describe the solution you'd like.

Create structs such as PostActions and CommunityActions, and use those as fields in view structs, instead of things like like_score being top-level fields.

Describe alternatives you've considered.

Maybe use shared structs that have more than just the actions.

Additional context

No response

@dessalines
Copy link
Member

We'd also be able to use diesel_embed if we did that, which would make the selects a lot easier.

The downside would be that the views won't be as clear, especially since a lot of the actions are timestamps. But I'd still be in favor of this as it'd clean up the code a lot.

@Nutomic
Copy link
Member

Nutomic commented Mar 4, 2025

Then we can probably get rid of AssumeNotNull too

@dessalines
Copy link
Member

dessalines commented Mar 4, 2025

This would be good to include in 1.0.0 then, since it would change all the structs a lot.

After #5407 is merged, we can work on this. I can do it if no one else wants to, and because I did a lot of this already for the combined views. Or @dullbananas if you'd rather do it, lmk.

EDIT: I started working on it.

@dessalines dessalines added this to the 1.0.0 milestone Mar 4, 2025
@dessalines dessalines linked a pull request Mar 7, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants