-
Notifications
You must be signed in to change notification settings - Fork 11
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
Extend graphql queries with a geo query #3084
Draft
ysf-simsoft
wants to merge
5
commits into
main
Choose a base branch
from
GH-3043-extend-graphql-queries-with-a-geo-query
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e12a116
nci-agency/anet#3043: Configure mssql and psql for geosearch queries
ysf-simsoft 63f2ba5
nci-agency/anet#3043: Add geosearch query for locations
ysf-simsoft 04409f1
nci-agency/anet#3043: Add geosearch query for reports
ysf-simsoft cda4cdc
nci-agency/anet#3043: Add geosearch query for positions
ysf-simsoft 304ce58
nci-agency/anet#3043: Add e2e api tests for geosearch queries
ysf-simsoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
import { expect } from "chai" | ||
import lodash from "lodash" | ||
|
||
const axios = require("axios") | ||
|
||
const apiUrl = `${process.env.SERVER_URL}/graphql?user=erin&pass=erin` | ||
|
||
// centered on General Hospital, zoom level 15, not padded | ||
const polygon01 = | ||
"POLYGON ((-52.77621746063233 47.56453866910163, -52.741935 47.56453866910163, -52.70763874053956 47.56453866910163, -52.70763874053956 47.571772, -52.70763874053956 47.57901543200339, -52.741935 47.57901543200339, -52.77621746063233 47.57901543200339, -52.77621746063233 47.571772, -52.77621746063233 47.56453866910163))" | ||
|
||
// centered on General Hospital, zoom level 15, padded by 0.5 | ||
const polygon02 = | ||
"POLYGON ((-52.81050682067872 47.55730028765075, -52.741935 47.55730028765075, -52.67334938049317 47.55730028765075, -52.67334938049317 47.571772, -52.67334938049317 47.58625381345426, -52.741935 47.58625381345426, -52.81050682067872 47.58625381345426, -52.81050682067872 47.571772, -52.81050682067872 47.55730028765075))" | ||
|
||
// centered on General Hospital, zoom level 11, padded by 0.5 | ||
const polygon03 = | ||
"POLYGON ((-57.13165283203125 46.642388783472754, -52.741935 46.642388783472754, -48.35357666015625 46.642388783472754, -48.35357666015625 47.571772, -48.35357666015625 48.49544709355706, -52.741935 48.49544709355706, -57.13165283203125 48.49544709355706, -57.13165283203125 47.571772, -57.13165283203125 46.642388783472754))" | ||
|
||
const locationQueryTemplate = { | ||
operationName: null, | ||
variables: { | ||
locationQuery: { | ||
pageSize: 0, | ||
withinPolygon: "", | ||
sortBy: "NAME" | ||
} | ||
}, | ||
query: ` | ||
query($locationQuery: LocationSearchQueryInput) { | ||
locationList(query: $locationQuery) { | ||
totalCount | ||
list { | ||
name | ||
} | ||
} | ||
} | ||
` | ||
} | ||
|
||
const reportQueryTemplate = { | ||
operationName: null, | ||
variables: { | ||
reportQuery: { | ||
pageSize: 0, | ||
state: "PUBLISHED", | ||
sortBy: "ENGAGEMENT_DATE", | ||
withinPolygon: "" | ||
} | ||
}, | ||
query: ` | ||
query ($reportQuery: ReportSearchQueryInput) { | ||
reportList(query: $reportQuery) { | ||
totalCount | ||
list { | ||
location { | ||
name | ||
} | ||
} | ||
} | ||
} | ||
` | ||
} | ||
|
||
const positionQueryTemplate = { | ||
operationName: null, | ||
variables: { | ||
positionQuery: { | ||
pageSize: 0, | ||
withinPolygon: "" | ||
} | ||
}, | ||
query: ` | ||
query ($positionQuery: PositionSearchQueryInput) { | ||
positionList(query: $positionQuery) { | ||
totalCount | ||
list { | ||
name | ||
location { | ||
name | ||
} | ||
} | ||
} | ||
} | ||
` | ||
} | ||
|
||
describe("Location geo search, when map center is (-52.741935 47.571772)", () => { | ||
it("should return one location for visible map bounds", async() => { | ||
const query = lodash.cloneDeep(locationQueryTemplate) | ||
query.variables.locationQuery.withinPolygon = polygon01 | ||
const result = await axios.post(apiUrl, query) | ||
expect(result?.status).to.equal(200) | ||
|
||
const resultList = result?.data?.data?.locationList?.list || [] | ||
expect(resultList.length).to.equal(1) | ||
expect(resultList[0].name).to.equal("General Hospital") | ||
}) | ||
|
||
const locations01 = [ | ||
"Cabot Tower", | ||
"Fort Amherst", | ||
"General Hospital", | ||
"Murray's Hotel", | ||
"Wishingwells Park" | ||
] | ||
|
||
it("should return 5 locations for padded (0.5) map bounds", async() => { | ||
const query = lodash.cloneDeep(locationQueryTemplate) | ||
query.variables.locationQuery.withinPolygon = polygon02 | ||
const result = await axios.post(apiUrl, query) | ||
expect(result?.status).to.equal(200) | ||
|
||
const resultList = result?.data?.data?.locationList?.list || [] | ||
expect(resultList.length).to.equal(5) | ||
expect(resultList[0].name).to.equal(locations01[0]) | ||
expect(resultList[1].name).to.equal(locations01[1]) | ||
expect(resultList[2].name).to.equal(locations01[2]) | ||
expect(resultList[3].name).to.equal(locations01[3]) | ||
expect(resultList[4].name).to.equal(locations01[4]) | ||
}) | ||
|
||
it("should return 9 locations in zoom level 11 for padded (0.5) map bounds", async() => { | ||
const query = lodash.cloneDeep(locationQueryTemplate) | ||
query.variables.locationQuery.withinPolygon = polygon03 | ||
const result = await axios.post(apiUrl, query) | ||
expect(result?.status).to.equal(200) | ||
|
||
const resultList = result?.data?.data?.locationList?.list || [] | ||
expect(resultList.length).to.equal(9) | ||
expect(resultList[0].name).to.equal("Cabot Tower") | ||
expect(resultList[1].name).to.equal("Conception Bay South Police Station") | ||
expect(resultList[2].name).to.equal("Fort Amherst") | ||
expect(resultList[3].name).to.equal("General Hospital") | ||
expect(resultList[4].name).to.equal("Harbour Grace Police Station") | ||
expect(resultList[5].name).to.equal("Murray's Hotel") | ||
expect(resultList[6].name).to.equal("Portugal Cove Ferry Terminal") | ||
expect(resultList[7].name).to.equal("St Johns Airport") | ||
expect(resultList[8].name).to.equal("Wishingwells Park") | ||
}) | ||
|
||
it("should return reports in only General Hospital for visible map bounds", async() => { | ||
const query = lodash.cloneDeep(reportQueryTemplate) | ||
query.variables.reportQuery.withinPolygon = polygon01 | ||
const result = await axios.post(apiUrl, query) | ||
expect(result?.status).to.equal(200) | ||
|
||
const resultList = result?.data?.data?.reportList?.list || [] | ||
expect(resultList.length).to.be.gt(1) | ||
expect( | ||
resultList.every(r => r.location.name === "General Hospital") | ||
).to.equal(true) | ||
}) | ||
|
||
it(`should return reports from any of "${locations01.join()}" for padded (0.5) map bounds`, async() => { | ||
const query = lodash.cloneDeep(reportQueryTemplate) | ||
query.variables.reportQuery.withinPolygon = polygon02 | ||
const result = await axios.post(apiUrl, query) | ||
expect(result?.status).to.equal(200) | ||
|
||
const resultList = result?.data?.data?.reportList?.list || [] | ||
expect(resultList.length).to.be.gt(1) | ||
resultList.forEach(r => expect(r.location.name).to.be.oneOf(locations01)) | ||
}) | ||
|
||
it("shouldn't return any positions for visible map bounds", async() => { | ||
const query = lodash.cloneDeep(positionQueryTemplate) | ||
query.variables.positionQuery.withinPolygon = polygon01 | ||
const result = await axios.post(apiUrl, query) | ||
expect(result?.status).to.equal(200) | ||
|
||
const resultList = result?.data?.data?.positionList?.list || [] | ||
expect(resultList.length).to.equal(0) | ||
}) | ||
|
||
it("should return one position for padded map bounds", async() => { | ||
const query = lodash.cloneDeep(positionQueryTemplate) | ||
query.variables.positionQuery.withinPolygon = polygon02 | ||
const result = await axios.post(apiUrl, query) | ||
expect(result?.status).to.equal(200) | ||
|
||
const resultList = result?.data?.data?.positionList?.list || [] | ||
expect(resultList.length).to.equal(1) | ||
expect(resultList[0].name).to.equal("Planning Captain") | ||
expect(resultList[0].location.name).to.equal("Wishingwells Park") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/mil/dds/anet/beans/search/LocationSearchQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please add a comment why this extension is added.