-
Notifications
You must be signed in to change notification settings - Fork 25
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
Create View for /listings endpoint #1621
Comments
This is essentially what I was picturing, yeah! How often do you think a view might be a superset of another view? For example, the listing page will be a superset of the view used for the listings list, right? In that case, we could have something like
right? I'm not sure if that would override the original Another way I had been considering (and I don't know if this is better) would be:
and then the querybuilder just uses it like In that world, the "inheritance" would be something like
Although a) I don't think you can reference fields on the same object so these might have to be properties of a class for that format to work? and b) it exposes the field names and such to the rest of the service (which is probably fine but could allow someone to add additional selects outside of this framework) This also points toward moving the selects and joins for the query that will be added in #1578 to support filtering into their own view (maybe called |
@avaleske ,
Then in the service endpoints we can do:
I'd like to start testing out these options tomorrow and have a PR ready at the beginning of next week, so let me know if your team feels strongly about one direction over the other, otherwise we can iterate off of the PR. |
I like your idea to use classes, @seanmalbert! I don't think we have strong opinions about one way or the other, but tagging @willrlin, @anders-schneider, and @abbiefarr who've also been thinking about the data models. Also I realize the code is just a sketch, but it inspires a few questions:
Additionally, if building these view grows to be complex or turns out to not lend itself well to this inheritance model, I could see it being helpful to have a wrapper |
I was thinking about this more and I realized another thing: Given that, for simplicity, the base* query could probably join everything we might need, and then each view just specifies the selects it wants (maybe after removing duplicates from the array of selects if TypeORM doesn't do that already). That'd probably be easier to reason about. *I'm using "base" to refer to the minimal view for the Listings List, and "inner query" to refer to the subquery that returns a list of query ids that match the current filters and pagination params. |
I'm sorry I wasn't as clear as I could have been. In this example, it would come from the instantiation of AnotherView (passed as
I was thinking a little ahead here, as part of the steps to add our next jurisdiction, we need to update all of the relevant tables to reference jurisdiction_id. I was thinking that we could have a base view which included adding a where clause with the jurisdiction_id applied. I think for this case though, we can leave out the generic. And I like the idea of the |
Since I did a little work this morning, I think I better understand your questions and what you were getting at. It doesn't make since to have fields or any of those args, for that matter, passed in at all with the extension model, and that they are indeed just properties on the class. |
Closed in #1626 |
From discussion in #1563 , we want to create a way to specify a "view" as a parameter to the GET listings endpoint (e.g.
\listings?page=2&limit=10&view=simpleListings
). This view should return the bare minimum needed for the main listings page, which uses the ListingsList component. These fields are:I'm thinking that the listings service can have map of views, with each view being a function that takes a query builder like:
There are likely DTOs that need updating, because they probably require fields that won't be returned from this query.
Since we will only need byUnitTypeAndRent from unitsSummarized, the call for summarizedUnitsByTypeAndRent should be abstracted from transformUnits so we don't have to calculate all of it.
The text was updated successfully, but these errors were encountered: