-
Notifications
You must be signed in to change notification settings - Fork 56
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
refactor: Replace hard code page size. #2622
refactor: Replace hard code page size. #2622
Conversation
ready for review @lukebp |
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 still seeing a lot of hardcoded page sizes.
$ grep -rinI --exclude-dir={node_modules,build,bin} page_size *
src/containers/Proposal/helpers.js:33: PROPOSAL_PAGE_SIZE,
src/containers/Proposal/helpers.js:458: pageSize = PROPOSAL_PAGE_SIZE
src/containers/Proposal/User/hooks.js:24:import { PROPOSAL_PAGE_SIZE } from "src/constants";
src/containers/Proposal/User/hooks.js:84: proposalPageSize = PROPOSAL_PAGE_SIZE,
src/containers/Proposal/User/Submitted.jsx:14:const PAGE_SIZE = 20;
src/containers/Proposal/User/Submitted.jsx:60: amountOfMissingProposals > PAGE_SIZE ? PAGE_SIZE : amountOfMissingProposals;
src/containers/Proposal/Download/hooks.js:11:const TIMESTAMPS_PAGE_SIZE = 100;
src/containers/Proposal/Download/hooks.js:18: const multiPage = votesCount > TIMESTAMPS_PAGE_SIZE;
src/containers/Proposal/Download/hooks.js:25: total ? ((total * TIMESTAMPS_PAGE_SIZE) / votesCount).toFixed(0) : 0,
src/containers/Comments/Download/hooks.js:38:const TIMESTAMPS_PAGE_SIZE = 100;
src/containers/Comments/Download/hooks.js:53: const multiPage = commentsLength > TIMESTAMPS_PAGE_SIZE;
src/containers/Comments/Download/hooks.js:62: take(TIMESTAMPS_PAGE_SIZE)(commentIds),
src/containers/Comments/Download/hooks.js:63: takeRight(commentIds.length - TIMESTAMPS_PAGE_SIZE)(commentIds)
src/constants.js:102:export const PROPOSAL_PAGE_SIZE = 5;
src/constants.js:103:export const INVENTORY_PAGE_SIZE = 20;
src/components/RecordsView/RecordsView.jsx:12: PROPOSAL_PAGE_SIZE
src/components/RecordsView/RecordsView.jsx:68: pageSize = PROPOSAL_PAGE_SIZE,
src/hooks/api/useProposalsBatch.js:26: INVENTORY_PAGE_SIZE,
src/hooks/api/useProposalsBatch.js:27: PROPOSAL_PAGE_SIZE,
src/hooks/api/useProposalsBatch.js:92: proposalPageSize = PROPOSAL_PAGE_SIZE,
src/hooks/api/useProposalsBatch.js:93: inventoryPageSize = INVENTORY_PAGE_SIZE
src/hooks/api/useApprovedProposals.js:5:const PAGE_SIZE = 20;
src/hooks/api/useApprovedProposals.js:25: PAGE_SIZE
teste2e/cypress/e2e/proposal/list.js:12:const RECORDS_PAGE_SIZE = 5;
teste2e/cypress/e2e/proposal/list.js:186: cy.assertListLengthByTestId("record-title", RECORDS_PAGE_SIZE) // first records batch
teste2e/cypress/e2e/proposal/list.js:260: cy.assertListLengthByTestId("record-title", RECORDS_PAGE_SIZE).each(
Some of those are my mistake. But some others are I leave to be a default value. Do you want to remove those completely? |
Hrmm some are not related to the backend page size and I used for other purposes. Examples: Those I guess can stay for now, but all the API related ones should be removed. |
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.
@@ -5,6 +5,9 @@ import ProposalLoader from "src/components/Proposal/ProposalLoader"; | |||
import useQueryStringWithIndexValue from "src/hooks/utils/useQueryStringWithIndexValue"; | |||
import { tabValues, statusByTab } from "./helpers"; | |||
import { mapProposalsTokensByTab } from "src/containers/Proposal/helpers"; | |||
import usePolicy from "src/hooks/api/usePolicy"; | |||
// XXX change to AdminActionsProvider |
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 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.
May be it is generated automatically from code editor. I will remove it now. Thanks for your review @amass01
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.
Looks good, left one inline comment.
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.
LGTM
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.
@vibros68
you posted e2e tests only of one file.
also you exported all consts even though they are used only locally
i think we should export only the ones used outside the file.
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 see many tests are missing, run the following command to run all tests in teminal:
yarn test:e2e:run
Also make sure you don't have any .only on one of the tests.
Please don't post the test results in the PR commit message, makes it unreadable
a separate comment is ok, see my comment here #2629 (comment) as an example -
you can add collapsable sections to github's markdown which is quite useful is such cases.
Full detail teste2e for #ed27150 Click to expand!
|
@@ -108,7 +108,7 @@ describe("Proposal Edit", () => { | |||
}) => { | |||
cy.approveProposal(censorshiprecord); | |||
cy.visit(`record/${shortRecordToken(censorshiprecord.token)}`); | |||
cy.wait(1000); | |||
cy.wait(3000); |
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.
why you need to wait 3 seconds here ?
if you are waiting to some API request, then wait for it
explicitly as we do in all other tests waiting for API requests.
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.
- Your logs are full of warnings/errors where are they coming from ?
...
Admin proposals actions
✓ Should allow admins to approve propsoals (24456ms)
[HPM] Error occurred while trying to proxy request /comments/v1/comments from localhost:3000 to https://localhost:4443 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
✓ Should allow admins to report a proposal as a spam (23389ms)
✓ Should allow admins to abandon proposals (20140ms)
✓ Should allow proposal author to authorize voting (19863ms)
[HPM] Error occurred while trying to proxy request /comments/v1/votes from localhost:3000 to https://localhost:4443 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while trying to proxy request /comments/v1/votes from localhost:3000 to https://localhost:4443 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
✓ Should allow admins to set the billing status of an active propsoal (24456ms)
[HPM] Error occurred while trying to proxy request /comments/v1/votes from localhost:3000 to https://localhost:4443 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while trying to proxy request /comments/v1/votes from localhost:3000 to https://localhost:4443 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while trying to proxy request /comments/v1/comments from localhost:3000 to https://localhost:4443 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
✓ Should allow admins to set the billing status of a closed propsoal (23878ms)
[HPM] Error occurred while trying to proxy request /comments/v1/votes from localhost:3000 to https://localhost:4443 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while trying to proxy request /comments/v1/votes from localhost:3000 to https://localhost:4443 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while trying to proxy request /comments/v1/comments from localhost:3000 to https://localhost:4443 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
✓ Should allow admins to set the billing status of a completed propsoal (23569ms)
✓ Shouldn't allow admins set a billing status when number of billing status changes exceeds the `billingstatuschangesmax` policy (20317ms)
...
Some requests to the server is failed. It becauses my computer is weak. When it is running heavy it losts some requests |
About changed from 1 second to 3 seconds. It is not waitting for an api request. It is after creating a proposal and click edit button. But because my laptop is weak and while running entire the teste2e. It becomes very slow. If I let 1 sec on there. The test will not stable. Some time it is passed and some time it is not. @amass01 |
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.
tACK list view on firefox.
Closes #2604.
decred/politeia#1518 adds the page sizes to the policy replies. This
diff replace hardcoded page sizes to be the policy reply values.