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
Create abaquery forums #3549
Create abaquery forums #3549
Conversation
f29c249
to
fc764d1
Compare
@@ -192,6 +194,7 @@ | |||
r"surveys/(?P<survey_pk>\d+)/submissions", SubmissionViewSet, basename="submission" | |||
) | |||
router.register(r"tags", TagViewSet) | |||
router.register(r"threads", ThreadViewSet) |
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.
Was going to leave this comment on your lego-webapp PR, because I think it would simplify quite a bit of logic and over-fetching of information - but I'll leave it here as this is the source if the suggestion.
The way I understand the relationships between the models, the relationships are as follows:
- A forum has 0-to-many threads, and a single thread has only one parent forum
- A thread has 0-to-many comments, and a single comment has only one parent thread
If this is the case, have you considered changing the API URL structure to something like
/forums/
-> PublicForum[] with pagination/forums/<id>
-> DetailedForum/forums/<id>/threads
-> PublicThread[] with pagination/forums/<id>/threads/<id>
-> DetailedThread/forums/<id>/threads/<id>/comments
-> DetailedComment[] with pagination
With this structure, you could fetch data in the frontend and put it directly into the state, as it will already be in the format you want to use it (instead of having to filter through every thread to find the threads relevant to the one forum you are currently in).
It would also allow you to simply fetch the threads relevant to your current forum, instead of having to fetch all threads and filter them on the frontend - which imo is a bad practice and could lead to a lot of unnecessary fetching if there are lots of threads (for example, what would happen if you load the 10 first threads with the current implementation, then you filter them on the frontend, but it turns out all the first threads belonged to another forum - so you have to fetch another page of threads, not knowing if any of those are going to be relevant to the forum you actually want before you have filtered them in the frontend)
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.
Okay thanks for the feedback I will look into this closer, this seems like a good suggestion
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.
The threads only have a unique ID though which is not relative to the parent forum. Do you still think /forum/id/thread/id would make sense in this case?
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.
Personally yeah, I think that would make sense - or you could change to slugs so it would be something like /forum/abahus/threads/kollektiv-paa-mollenberg
, /forum/abahus/kollektiv-paa-mollenberg
or /forum/abahus/threads/419
.
There are many ways to design this though - I'm just suggesting this as I think it's one of the more popular designs and thus easier to understand right away. Plus it's closer to the actual use in the frontend requiring less filtering and logic there.
Although I'd guess that the others you have requested reviews from get this, or at least my first comment on email - so if there are other thoughts on this feel free to share(:
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.
Okay, trying to add these but it seems we strictly use the router and not urlpatterns. Not sure if I'm allowed to change this and add some custom routes like this:
path('<int:forum_id>/threads/', ThreadViewSet.as_view({'get': 'list', 'post': 'create'}), name='forum-threads-list'),
I added it now but I think @ivarnakken will have some thoughts about this...
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.
haha this is completely fine by me. I think @norbye's suggestion is good.
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'm not sure why you need this custom routing config though
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 don't think using router.register supports custom patterns like this?
I've now updated it in backend and front-end.
Issue is still that action_grant is only send on list endpoint so either I need to pass it down or refetch list on every page which seems dumb...
Also, would an offset pagination make more sense in this case than pointer?
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 don't think using router.register supports custom patterns like this?
Think you're right about that one, unless we go into the business of 3rd party extensions, which seems unnecessary.
Issue is still that action_grant is only send on list endpoint so either I need to pass it down or refetch list on every page which seems dumb...
I haven't looked into how we actually handle the action grants, but I know that /events sends action grants to each event - so I would assume thats not too complicated to do here as well.
Also, would an offset pagination make more sense in this case than pointer?
Personally I don't really mind either way - but either way I'd think that could be something for another PR down the line
0e7bd26
to
e00b525
Compare
787014a
to
cdd26f1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3549 +/- ##
========================================
Coverage 88.24% 88.24%
========================================
Files 670 678 +8
Lines 21089 21393 +304
========================================
+ Hits 18609 18879 +270
- Misses 2480 2514 +34 ☔ View full report in Codecov by Sentry. |
@ivarnakken Could this be merged now that tests pass? |
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.
Been a while since I worked on anything in the backend - so take it with a pinch of salt - but looks good to me(:
@@ -192,6 +196,7 @@ | |||
r"surveys/(?P<survey_pk>\d+)/submissions", SubmissionViewSet, basename="submission" | |||
) | |||
router.register(r"tags", TagViewSet) | |||
router.register(r"threads", ThreadViewSet) |
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.
Might want to delete this now that the other endpoint is implemented
@@ -192,6 +194,7 @@ | |||
r"surveys/(?P<survey_pk>\d+)/submissions", SubmissionViewSet, basename="submission" | |||
) | |||
router.register(r"tags", TagViewSet) | |||
router.register(r"threads", ThreadViewSet) |
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 don't think using router.register supports custom patterns like this?
Think you're right about that one, unless we go into the business of 3rd party extensions, which seems unnecessary.
Issue is still that action_grant is only send on list endpoint so either I need to pass it down or refetch list on every page which seems dumb...
I haven't looked into how we actually handle the action grants, but I know that /events sends action grants to each event - so I would assume thats not too complicated to do here as well.
Also, would an offset pagination make more sense in this case than pointer?
Personally I don't really mind either way - but either way I'd think that could be something for another PR down the line
@norbye Thanks for the review, however, I've resolved the article issue and I think I'll be merging this (assuming that's okay) just to get the MVP out. |
97b1b85
to
36161fb
Compare
36161fb
to
fd5913a
Compare
Create the abaquery forum backend.
Resolves: ABA-561