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

Move cross-table api counts into plugin #6038

Merged
merged 1 commit into from
Nov 3, 2015

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Nov 3, 2015

Another piece of refactoring work on the way to making it possible to add cross-table counts etc.

The key thing here, is that rather than having a util that is then called inside the pagination plugin and the tag.read function, and would reasonably have to be called at other points too, we now have a plugin that automatically gets called at the right times.

This makes it easier to add support for counts on other models / relationships. Although, I still need to figure out how to add the behaviour so that only the correct posts are counted (what I'm working on next...)


One thing that has occurred to me is to use this fetch/fetchAll override pattern to create a query-building hook system into fetch/fetchAll and allow for the registering of functions to be called by that hook if certain options exist.

E.g.

  • if there is a count property in an include, call count handling
  • if there is an order property in the options, call order handling
  • if there is an group property in the options, call group handling

I think this could work to further simplify our code for building queries.

refs #6009, #5615

  • minimal refactor to remove the addition of count from pagination and other various points
  • create a include count plugin that overrides fetch and fetchAll
  • this ensures that counts get added at the right points

refs TryGhost#6009, TryGhost#5615

- minimal refactor to remove the addition of count from pagination and other various points
- create a include count plugin that overrides fetch and fetchAll
- this ensures that counts get added at the right points
sebgie added a commit that referenced this pull request Nov 3, 2015
Move cross-table api counts into plugin
@sebgie sebgie merged commit d81ddc9 into TryGhost:master Nov 3, 2015
@ErisDS ErisDS deleted the count-refactor branch November 23, 2015 17:35
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.

2 participants