Skip to content
Permalink
Browse files

Pr outside range (#442)

* show full appid in update

* getPullRequest should find prId outside date range

* fixed date conversion
  • Loading branch information...
tympollack authored and jdereg committed Feb 23, 2018
1 parent c6acfef commit cacdd63a49d8270b42785355c114621aa3096b34
@@ -1,6 +1,6 @@
### Revision History
* 4.2.5-SNAPSHOT
* --
* `NCubeManager.getPullRequests()' can now accept a pull request ID to find if it's otherwise outside of the date range.
* 4.2.4
* NCube.mapReduce() - input/output Map when passed in was not getting used if it was empty (Groovy truth - empty map is false - threw off comparison). @gmorefield.
* NCube.mapReduce() - when ran against a rule cube, the row and column axis names need to be added to the tracking map. @gmorefield.
Binary file not shown.
@@ -1400,9 +1400,9 @@ class NCubeController implements NCubeConstants
}

@SuppressWarnings("GroovyUnusedDeclaration")
Object[] getPullRequests(Date startDate = null, Date endDate = null)
Object[] getPullRequests(Date startDate = null, Date endDate = null, String prId = null)
{
Object[] pullRequests = mutableClient.getPullRequests(startDate, endDate)
Object[] pullRequests = mutableClient.getPullRequests(startDate, endDate, prId)
return pullRequests
}

@@ -2676,7 +2676,7 @@ target axis: ${transformApp} / ${transformVersion} / ${transformCubeName}, user:
} as NCube
}

Object[] getPullRequests(Date startDate = null, Date endDate = null)
Object[] getPullRequests(Date startDate = null, Date endDate = null, String prId = null)
{
List<Map> results = []
if (!startDate) {
@@ -2686,6 +2686,10 @@ target axis: ${transformApp} / ${transformVersion} / ${transformCubeName}, user:
}

List<NCube> cubes = getPullRequestCubes(startDate, endDate)
if (prId && !cubes.find {it.name.contains(prId)}) {
cubes.add(loadPullRequestCube(prId))
}

for (NCube cube : cubes)
{
Map prInfo = cube.getMap([(PR_PROP):[] as Set])
@@ -2694,7 +2698,10 @@ target axis: ${transformApp} / ${transformVersion} / ${transformCubeName}, user:
prInfo[PR_TXID] = cube.name.substring(3)
results.add(prInfo)
}
results.sort(true, {Map a, Map b -> Converter.convert(b[PR_REQUEST_TIME], Date.class) as Date <=> Converter.convert(a[PR_REQUEST_TIME], Date.class) as Date})
results.sort(true, { Map a, Map b ->
Converter.convertToDate(b[PR_REQUEST_TIME]) <=> Converter.convertToDate(a[PR_REQUEST_TIME]) ?:
Converter.convertToDate(b[PR_MERGE_TIME]) <=> Converter.convertToDate(a[PR_MERGE_TIME])
})
return results as Object[]
}

@@ -131,8 +131,8 @@ interface NCubeMutableClient extends NCubeClient
void reopenPullRequest(String prId)

Object[] getPullRequests()

Object[] getPullRequests(Date startDate, Date endDate)
Object[] getPullRequests(Date startDate, Date endDate, String prId)

Map<String, Object> commitBranch(ApplicationID appId)

@@ -797,10 +797,10 @@ class NCubeRuntime implements NCubeMutableClient, NCubeRuntimeClient, NCubeTestC
bean.call(beanName, 'reopenPullRequest', [prId]) as NCube
}

Object[] getPullRequests(Date startDate = null, Date endDate = null)
Object[] getPullRequests(Date startDate = null, Date endDate = null, String prId = null)
{
verifyAllowMutable('getPullRequests')
Object[] result = bean.call(beanName, 'getPullRequests', [startDate, endDate]) as Object[]
Object[] result = bean.call(beanName, 'getPullRequests', [startDate, endDate, prId]) as Object[]
return result
}

@@ -162,6 +162,25 @@ class TestPullRequests extends NCubeCleanupBaseTest
assert test2Notes == prs[1][PR_ID]
}

@Test
void testGetPullRequestIdOutsideDateRange()
{
String test1Notes = 'test1'
preloadCubes(ApplicationID.testAppId, 'test.branch.1.json', 'test.branch.age.1.json')
List<NCubeInfoDto> branchDtos = mutableClient.search(appId, 'TestBranch', null, null)
String prId = mutableClient.generatePullRequestHash(appId, branchDtos.toArray(), test1Notes)

Calendar c = Calendar.instance
c.add(Calendar.DATE, -10)
Date date = c.time
Object[] prs = mutableClient.getPullRequests(date, date, prId)
assert 1 == prs.length
assert test1Notes == prs[0][PR_ID]

mutableClient.getPullRequests(null, null, prId)
assert 1 == prs.length // if prId is within date range, should not have duplicates
}

@Test
void testMergeOwnPullRequest()
{

0 comments on commit cacdd63

Please sign in to comment.
You can’t perform that action at this time.