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

2037 add review date #2044

Merged
merged 4 commits into from
Apr 1, 2021
Merged

2037 add review date #2044

merged 4 commits into from
Apr 1, 2021

Conversation

WinnyTroy
Copy link
Contributor

Changes / Features implemented

Adds submission review dates to data endpoint response

Steps taken to verify this change does what is intended

Updated tests
QA

Closes #2037

@WinnyTroy WinnyTroy force-pushed the 2037-add-review-date branch 3 times, most recently from cf3c965 to 7611263 Compare March 29, 2021 07:42
status = review.status
comment = review.get_note_text()
review_date = review.date_created
return status, comment, review_date
except SubmissionReview.DoesNotExist:
return None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the None portion is not being tested, it could be a source of potential bug, I would expect 3 None's to be returned.

Comment on lines 444 to 445
def get_review_status_and_comment(self):
def get_review_details(self):
Copy link
Member

@ukanga ukanga Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to be hesitant in renaming functions that have been around for a long time, in this case about 3 years. I would perhaps recommend a new method:

def get_latest_review(self):
    try:
        return self.reviews.latest('date_modified')
    except SubmissionReview.DoesNotExist:
        return None

Which then we can use as

review = self.get_latest_review()
if review:
    doc[REVIEW_STATUS] = review.status
    doc[REVIEW_COMMENT] = review.get_note_text() or ""
    doc[REVIEW_DATE] = review.date_created.strftime(MONGO_STRFTIME)

I think this approach is much cleaner and clearer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also means you do not end up having to rename old functions, you could mark the old function deprecated so that we eventually change its reference everywhere.

@WinnyTroy WinnyTroy force-pushed the 2037-add-review-date branch 2 times, most recently from c209646 to 782c31d Compare April 1, 2021 08:49
Return a tuple of review status and comment
Return a tuple of review status and comment.
Deprecated in favour of `get_latest_review`
TODO: Clean code of this unused function.
Copy link
Contributor

@DavisRayM DavisRayM Apr 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should use something like the Deprecated library or a custom decorator like this; to mark deprecated functions ?

TODOs usually get forgotten IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this.
I've used the pip deprecated package for this. Seemed cleaner.

@WinnyTroy WinnyTroy force-pushed the 2037-add-review-date branch 2 times, most recently from e213203 to fc0c9dc Compare April 1, 2021 12:00
ukanga
ukanga previously approved these changes Apr 1, 2021
Use deprecated pip package to deprecate `get_review_status_and_comment` function
@DavisRayM DavisRayM merged commit bc58cfa into master Apr 1, 2021
@DavisRayM DavisRayM deleted the 2037-add-review-date branch April 1, 2021 14:08
@DavisRayM DavisRayM mentioned this pull request Apr 21, 2021
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add submission review date on data endpoint
4 participants