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

🔀 Add search API #53

Merged
merged 4 commits into from
Jun 21, 2018
Merged

🔀 Add search API #53

merged 4 commits into from
Jun 21, 2018

Conversation

inDream
Copy link
Contributor

@inDream inDream commented Jun 15, 2018

Connects #2

Due to database schema changes, seed data need to reset.
Command: npm run sequelize:reseed

@inDream inDream force-pushed the add-search branch 2 times, most recently from 2056e83 to 47f717d Compare June 20, 2018 04:51
@inDream inDream changed the title 🚧 Add search API 🔀 Add search API Jun 20, 2018
@inDream
Copy link
Contributor Author

inDream commented Jun 20, 2018

@rickmak @nwingt The API could review now, sample responses could refer to:
__tests__/integration/api/__snapshots__/search.test.js.snap

Pagination cursor currently contains offset and q (keyword) only.
Is first/last assets fingerprint or sort order needed?

Copy link
Collaborator

@rickmak rickmak left a comment

Choose a reason for hiding this comment

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

Please update the functional grouping of codes.

query,
} = req;
let offset = 0;
let q = decodeURIComponent(query.q || '');
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest the whole pagination logic to in an separate testable module in stead of putting inline here in the controller.

i.e. in server/utils/index:getPageInfo and the parseQuery here belong to server/utils/paginator and create Paginate class and PageInfo class to represent the logic here.

};
}

const { count, rows } = await sequelize.asset.findAndCountAll({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Put the SQL building model.asset?

@rickmak rickmak self-assigned this Jun 20, 2018
@rickmak rickmak merged commit f59e9bc into likecoin:master Jun 21, 2018
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.

None yet

2 participants