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

feat(hub-common): add viewDefinition and recordCount to fetchContent(… #744

Merged
merged 2 commits into from
Mar 16, 2022

Conversation

tomwayson
Copy link
Member

@tomwayson tomwayson commented Mar 16, 2022

…) response

affects: @esri/hub-common

  1. Description:

fetchContent now fetches the definition for client-side layer views
and fetches the record count for
layers, tables, and proxied CSVs

  1. Instructions for testing:

  2. Closes Issues:

#322 (essentially)

There are additional top-level aliases we could add like geometryType, capabilities, objectIdField, however, we've decided for now to update the client-code instead to get those from layer or server.

  1. ran commit script (npm run c)

…) response

affects: @esri/hub-common

fetchContent now fetches the definition for client-side layer views
and fetches the record count for
layers, tables, and proxied CSVs
@codecov
Copy link

codecov bot commented Mar 16, 2022

Codecov Report

Merging #744 (4f7ed57) into master (57911f8) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #744   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          345       345           
  Lines         6484      6513   +29     
  Branches      1176      1188   +12     
=========================================
+ Hits          6484      6513   +29     
Impacted Files Coverage Δ
packages/common/src/content/_fetch.ts 100.00% <ø> (ø)
packages/common/src/content/compose.ts 100.00% <100.00%> (ø)
packages/common/src/content/fetch.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 23bf085...4f7ed57. Read the comment docs.

@tomwayson
Copy link
Member Author

tomwayson commented Mar 16, 2022

@sonofflynn89

NOTE: the explore view will expect content to have a top-level viewFilter, which we'll now need to handle like:

const getViewFilter = content => content.viewDefinition && `(${content.viewDefinition.definitionExpression})`

* @returns layer definition
* @private
*/
export const getItemLayer = (
Copy link
Member Author

Choose a reason for hiding this comment

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

this fn was just hoisted out of composeContent() below

const { item, data, layers } = itemAndEnrichments;
const layer =
layers && getItemLayer(item, layers, options && options.layerId);
// TODO: add recordCount here too?
Copy link
Member Author

@tomwayson tomwayson Mar 16, 2022

Choose a reason for hiding this comment

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

I'd prefer to fetch the record count here, where we fetch other enrichments, however, I need a lot of logic that currently only happens in composeContent() getters like isProxied, url, viewDefinition, so I'd have to turn all those getters into fns I could call here. So for now, I just fetch recordCount below in fetchContent() after calling composeContent()

Copy link
Contributor

@sonofflynn89 sonofflynn89 left a comment

Choose a reason for hiding this comment

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

Looks good! Just a couple comments about imports. Before you merge I'd like to talk about some of the layerView stuff for my own edification 👍

packages/common/src/content/_fetch.ts Outdated Show resolved Hide resolved
packages/common/src/content/_fetch.ts Outdated Show resolved Hide resolved
packages/common/src/content/_fetch.ts Outdated Show resolved Hide resolved
packages/common/src/content/fetch.ts Show resolved Hide resolved
layers && getItemLayer(item, layers, options && options.layerId);
// TODO: add recordCount here too?
const layerEnrichments =
layer && isLayerView(layer) && !data
Copy link
Member Author

Choose a reason for hiding this comment

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

I copied the current logic in isLayerView() from composer.js, which only checks layer.isView, but when creating a new layer view to test this I noticed that the item also gets the "View Service" type keyword. We could use that in fetchItemEnrichments() to include "data" in the default list of enrichments to fetch for the item, however, there are layer views that don't have that type keyword (for example the item in #1073), so we'd still have to do this check after fetching the layer.

? // NOTE: I'm not sure what conditions causes a layer view
// to store (at least part of) it's view definition in item data
// it seems that most do not, but until we have a reliable signal
// we just fetch the item data for all layer views
Copy link
Member Author

Choose a reason for hiding this comment

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

Furthermore, spot checking a handful of such items from this:
https://qaext.arcgis.com/sharing/rest/search?num=100&start=0&f=json&q=typekeywords%3A%22View%20Service%22
showed that very few had their definition stored in item data, ex:
https://qaext.arcgis.com/sharing/rest/content/items/864c9eaf76ab47ba93d7308bacf1a34f/data?f=json, so most of the time we're fetching the data for nothing.

@tomwayson tomwayson merged commit 3298518 into master Mar 16, 2022
@tomwayson tomwayson deleted the f/recordCount branch March 16, 2022 23:25
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