-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: add review status to API response #296
base: dev
Are you sure you want to change the base?
Conversation
chore(feat): add merged status to review for admin (#285) * chore(feat): add merged status to review for admin * chore: effect review comments Co-authored-by: nully0x <[email protected]>
fix: expired condition not return merged reviews (#288) * fix: expired review inference not return merged reviews * chore: remove unused buildIsInactiveCondition logic * fix: account for expired but not archived reviews * chore: rename 'buildIsExpiredAndArchivedOrNotArchivedCondition' to 'buidIsExpiredCondition' for simplicity. Also added comments explaining why we have the combined logic
* feat: Add evaluator role and permissions to user model and middleware The code changes include adding the "evaluator" role and permissions to the user model and updating the middleware to handle the new role. This allows for better access control and authorization for evaluators. * chore: clean up user section of swagger docs * refactor: authorize middleware function to be dynamic with user permissions * feat: Update username parameter in findByPublicProfile endpoint The code changes is necessary to follow RESTful OpenAPI convention where GET request shouldn't have a request body but can have query parameters
This commit adds 1. the functionality to compute the review status for all reviews when queried from the database. This computation is done on the API level and is not stored in the db. 2. a new "rejected" review status based on the criteria outlined [here](#294)
@Extheoisah how did you test this? I'm running this branch locally, but using the staging database and redis instance. I'm using the Edit: I wasn't using the correct setup, that's why it didn't work. I wanted to use the staging db, but I forgot that by having |
I tested using my local db. When you query the |
This commit adds the new "rejected" status to the buildCondition for the review
@kouloumos updated the code to include the "rejected" status in Swagger docs and also added it to the |
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.
There is something that doesn't feel right with the "duplicate" calculation of status
, once on the query using buildCondition()
and once for each result with computeReviewStatus()
.
I consulted my personal assistant ( 😎 ) for some ideas on how we can avoid this. Its suggestion was to either use triggers or create another view that will derive the status. It seems that both of those ideas get us back to having a single source of truth and simplify the implementation. The chat discussion offers more details about those alternative implementation directions. Please review the chat and let me know if these suggestions make sense to you
Additionally, I believe removing the notion of "archived" reviews could simplify our process. Currently, when querying for expired reviews, we must check both "archived" and "not archived" statuses. However, the expired status is already determined by whether a certain amount of time has passed. Thus, the "archived" status seems redundant. It might become useful for implementing different limits for different reviewers (see #286), but even then, we would still rely on createdAt to determine the timeframe.
This was initially my suggestion qhen this issue was raised #295 (comment) but you didn't agree with it. I'm glad after the 1st implementation following your suggestion you agree that the status column makes things easier. As regards removing the "archivedAt" column, the reasons you provided are not concrete enough for me to agree with removing the column. Remember we check for both "archived" and "not archived" statuses becuase of the cron job that runs every 24hrs to update the review status |
In my defense, at the time, you didn't provide a concrete way to do that and after I explained my thought process and how I was thinking about the downsides of adding the new column you agreed. So, what do you think about the proposed solutions for implementing the
What I am saying is that the cron jobs that runs every 24h to archive reviews doesn't offer any benefit as on both checks ( "archived" and "not archived" statuses) we are also checking if we are in the 24h hours timeframe from the review's creation. [Op.and]: {
mergedAt: { [Op.eq]: null }, // has not been merged
submittedAt: { [Op.eq]: null }, // has not been submitted
createdAt: { [Op.lt]: timeStringAt24HoursPrior }, // expired Does that make sense? |
Some context here: We wanted inferred states rather than declaring them. The Initially, I started with cron jobs to manage the queuing, but cron is in memory so whenever the process restarts (server restarts) we lose the cron/timing (next 24 hrs from createdAt). The I switched to In hindsight, I don't think the |
I agree that's the way forward. I'll work something out and see.
We can remove the cron job. The cron job was added a while back because we had one or two cases of non-archived but expired reviews. So the cron job was a fallback to catch those leaks. @Emmanuel-Develops would have more context to help us determine if we can remove it without any issues. |
🚀
You are right, I forgot that we are using |
74e3a93
to
9999e78
Compare
closes #294 and #295
This pr adds review status to the API response when a review detail is fetched from the db. This is done on the API level and not in the database level.
Also, a new "rejected" status has been added based on this criteria.