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

Fix #16069: Add a "Newest First" tag for reviewable questions #16534

Merged
merged 31 commits into from
Jan 10, 2023

Conversation

qinghaoyang
Copy link
Contributor

@qinghaoyang qinghaoyang commented Nov 13, 2022

Overview

  1. This PR fixes or fixes part of Sorting/Tagging questions by date #16069.
  2. This PR does the following: Added a filter to sort the reviewable questions by selected keys. Currently, the keys include 'Date', which sorts the questions with the newest first.

Essential Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The linter/Karma presubmit checks have passed locally on your machine.
  • "Allow edits from maintainers" is checked. (See here for instructions on how to enable it.)
    • This lets reviewers restart your CircleCI tests for you.
  • The PR is made from a branch that's not called "develop".

Proof that changes are correct

Screen.Recording.2022-12-29.at.8.14.44.PM.mov

The change does not create issues when clicking other tabs.

Screen.Recording.2023-01-08.at.5.08.52.PM.mov

PR Pointers

  • Make sure to follow the instructions for making a code change.
  • If you need a review or an answer to a question, and don't have permissions to assign people, leave a comment like the following: "{{Question/comment}} @{{reviewer_username}} PTAL". Oppiabot will help assign that person for you.
  • For what code owners will expect, see the Code Owner's wiki page.
  • Make sure your PR follows conventions in the style guide, otherwise this will lead to review delays.
  • Never force push. If you do, your PR will be closed.
  • Some of the e2e tests are flaky, and can fail for reasons unrelated to your PR. We are working on fixing this, but in the meantime, if you need to restart the tests, please check the "If your build fails" wiki page.

@oppiabot
Copy link

oppiabot bot commented Nov 13, 2022

Hi @qinghaoyang, can you complete the following:

  1. The body of this PR is missing the required description, please update the body with a description of what this PR does.
  2. The karma and linter checklist has not been checked, please make sure to run the frontend tests and lint tests before pushing.
    Thanks!

@oppiabot
Copy link

oppiabot bot commented Nov 13, 2022

Hi, @qinghaoyang, this pull request does not have a "CHANGELOG: ..." label as mentioned in the PR pointers. Assigning @qinghaoyang to add the required label. PRs without this label will not be merged. If you are unsure of which label to add, please ask the reviewers for guidance. Thanks!

@oppiabot
Copy link

oppiabot bot commented Nov 15, 2022

Hi @qinghaoyang, the build of this PR is stale and this could result in tests failing in develop. Please update this pull request with the latest changes from develop. Thanks!

@oppiabot oppiabot bot added PR: don't merge - STALE BUILD The build on this PR is stale and should be restarted. PR: don't merge - HAS MERGE CONFLICTS labels Nov 15, 2022
@oppiabot
Copy link

oppiabot bot commented Nov 19, 2022

Hi @qinghaoyang. Due to recent changes in the "develop" branch, this PR now has a merge conflict. Please follow this link if you need help resolving the conflict, so that the PR can be merged. Thanks!

@oppiabot
Copy link

oppiabot bot commented Nov 26, 2022

Hi @qinghaoyang, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 4 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 4 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale label Nov 26, 2022
@oppiabot
Copy link

oppiabot bot commented Nov 28, 2022

Hi @qinghaoyang, there is a new change in develop which needs to be in your PR. Please update your branch with the latest changes in develop. For instructions, refer to this link. Thanks!

@oppiabot
Copy link

oppiabot bot commented Nov 28, 2022

Hi @qinghaoyang, there is a new change in develop which needs to be in your PR. Please update your branch with the latest changes in develop. For instructions, refer to this link. Thanks!

@oppiabot oppiabot bot removed the PR: don't merge - STALE BUILD The build on this PR is stale and should be restarted. label Dec 6, 2022
@qinghaoyang qinghaoyang marked this pull request as ready for review December 6, 2022 05:45
@qinghaoyang qinghaoyang requested a review from a team as a code owner December 6, 2022 05:45
@qinghaoyang qinghaoyang requested a review from a team December 6, 2022 05:45
@qinghaoyang qinghaoyang requested a review from a team as a code owner December 6, 2022 05:45
@oppiabot
Copy link

oppiabot bot commented Jan 8, 2023

Hi @qinghaoyang, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 4 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 4 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added stale and removed stale labels Jan 8, 2023
@oppiabot oppiabot bot removed the PR: don't merge - STALE BUILD The build on this PR is stale and should be restarted. label Jan 9, 2023
Copy link
Contributor Author

@qinghaoyang qinghaoyang left a comment

Choose a reason for hiding this comment

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

@seanlip PTAL.

core/feconf.py Outdated
@@ -1638,6 +1638,9 @@ def get_empty_ratings() -> Dict[str, int]:
SUGGESTION_TYPE_ADD_QUESTION
]

# The sort keys of submitted questions shown on the Contributor Dashboard.
QUESTIONS_SORT_KEYS = ['Default', 'Date']
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted.

@@ -705,7 +705,7 @@ describe('Contributions and review component', () => {
expect(component.activeExplorationId).toBeNull();
}));

it('should return true on Review Translations tab', fakeAsync(() => {
it('should on Review Translations tab', fakeAsync(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

expect(alertsService.addSuccessMessage)
.toHaveBeenCalledWith('Submitted suggestion review.');
}));

it('should return false on Review Questions tab', () => {
it('should on Review Questions tab', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -515,6 +529,8 @@ export class ContributionsAndReview
this.TAB_TYPE_CONTRIBUTIONS = 'contributions';
this.TAB_TYPE_REVIEWS = 'reviews';
this.TAB_TYPE_ACCOMPLISHMENTS = 'accomplishments';
this.QUESTIONS_SORT_KEYS = ['Date'];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Changed 'Date' to the constant in constants.ts.

@@ -74,7 +74,9 @@ describe('Contribution and review backend API service', () => {
carbas.fetchSuggestionsAsync(
'SUBMITTED_QUESTION_SUGGESTIONS',
AppConstants.OPPORTUNITIES_PAGE_SIZE,
0, 'All'
0,
undefined,
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 the suggestion. Updated.

@qinghaoyang qinghaoyang requested a review from seanlip January 9, 2023 04:07
@qinghaoyang qinghaoyang assigned seanlip and unassigned qinghaoyang Jan 9, 2023
Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

Thanks @qinghaoyang! Replied, PTAL.

@@ -5857,7 +5857,8 @@ export default {
"translation", "voiceover", "question", "submit_question"
],

"QUESTIONS_SORT_KEY_DATE": "Date",
"SUGGESTIONS_SORT_KEY_DATE": "Date",
"SUGGESTIONS_SORT_KEY_NULL": "",
Copy link
Member

Choose a reason for hiding this comment

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

Can we not have this constant? This is because Null/None should be different from empty string -- we should actually pass null / None instead.

Also, if possible, I think we shouldn't allow a case where the output is unsorted anyway. If we always require a sort order, it would make things simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this line.

return this.fetchSuggestionsAsync(
this.userCreatedQuestionFetcher,
shouldResetOffset);
}

async getReviewableQuestionSuggestionsAsync(
shouldResetOffset: boolean = true,
sortKey?: string
sortKey: string = ''
Copy link
Member

Choose a reason for hiding this comment

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

This should be null if you don't actually have a sort key, rather than ''.

(Better to always have a sort key though, if possible.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed ''

@@ -768,18 +768,16 @@ describe('Contributions and review component', () => {
tick();

expect(component.isReviewTranslationsTab()).toBeTrue();
expect(component.isReviewQuestionsTab()).toBeFalse();
Copy link
Member

Choose a reason for hiding this comment

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

I think you can probably keep this assertion, it does no harm and is a reasonable check to make sure the calls are working correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

spyOn(component, 'openQuestionSuggestionModal').and.callFake(() => {
return;
});

component.switchToTab(component.TAB_TYPE_REVIEWS, 'add_question');
expect(component.isReviewTranslationsTab()).toBeFalse();
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@seanlip seanlip assigned qinghaoyang and unassigned seanlip Jan 9, 2023
Copy link
Contributor Author

@qinghaoyang qinghaoyang left a comment

Choose a reason for hiding this comment

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

@seanlip PTAL. Currently, the reviewable translations in the backend are not sorted. I added a feature to sort them by date, as I did for reviewable questions. Also, I added a video to show that the reviewable translations are sorted by date by default.

@@ -768,18 +768,16 @@ describe('Contributions and review component', () => {
tick();

expect(component.isReviewTranslationsTab()).toBeTrue();
expect(component.isReviewQuestionsTab()).toBeFalse();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

spyOn(component, 'openQuestionSuggestionModal').and.callFake(() => {
return;
});

component.switchToTab(component.TAB_TYPE_REVIEWS, 'add_question');
expect(component.isReviewTranslationsTab()).toBeFalse();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -5857,7 +5857,8 @@ export default {
"translation", "voiceover", "question", "submit_question"
],

"QUESTIONS_SORT_KEY_DATE": "Date",
"SUGGESTIONS_SORT_KEY_DATE": "Date",
"SUGGESTIONS_SORT_KEY_NULL": "",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this line.

return this.fetchSuggestionsAsync(
this.userCreatedQuestionFetcher,
shouldResetOffset);
}

async getReviewableQuestionSuggestionsAsync(
shouldResetOffset: boolean = true,
sortKey?: string
sortKey: string = ''
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed ''

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

Thanks @qinghaoyang! I think this looks great.

Just one question, can you check index.yaml to see if it has the right indexes to support the necessary queries? If not we'll need to add them, otherwise this will throw an error in production when we deploy it.

Also -- @vojtechjelinek I believe index.yaml used to autogenerate indexes, but I think it doesn't do that any more. Is that correct?

@qinghaoyang qinghaoyang requested a review from a team as a code owner January 10, 2023 16:12
@qinghaoyang
Copy link
Contributor Author

@seanlip PTAL.

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

Thanks @qinghaoyang! LGTM!

@seanlip seanlip removed their assignment Jan 10, 2023
@oppiabot oppiabot bot added the PR: LGTM label Jan 10, 2023
@oppiabot
Copy link

oppiabot bot commented Jan 10, 2023

Hi @qinghaoyang, this PR is ready to be merged. Please address any remaining comments prior to merging, and feel free to merge this PR once the CI checks pass and you're happy with it. Thanks!

@qinghaoyang qinghaoyang merged commit 0065c97 into oppia:develop Jan 10, 2023
@vojtechjelinek vojtechjelinek mentioned this pull request Jan 14, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants