Skip to content

Import groups#54

Merged
txsmith merged 8 commits intoisApproved-v2from
import-groups
Jun 29, 2017
Merged

Import groups#54
txsmith merged 8 commits intoisApproved-v2from
import-groups

Conversation

@eanker
Copy link
Collaborator

@eanker eanker commented Jun 22, 2017

No description provided.

@preview-code
Copy link

preview-code bot commented Jun 22, 2017

This pull request can be reviewed with Preview Code.
To speed up the review process and get better feedback on your changes, please order your changes.

githubService.setOrderingStatus(repoAndPull.second, pendingStatus);

//Add hunks to database
Diff diff = githubService.fetchDiff(repoAndPull.second);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Eventually, this should also be refactored into an Action<..> but for this PR it's fine

return insertPullIfNotExists(pull)
.then(this::clearExistingGroups)
.then(dbPullId -> traverse(groups, createGroup(dbPullId))).toUnit();
.then(dbPullId -> traverse(groups, createGroup(dbPullId, null))).toUnit();
Copy link
Collaborator

Choose a reason for hiding this comment

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

To avoid nulls floating in the code, I'd suggest we make this false and adjust DatabaseInterpreter.insertNewGroup to insert null if this parameter is false.

* @param diff to parse
* @return list of hunkChecksums
*/
public List<String> parseDiff(String diff) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the return type be List<HunkChecksum>? This is more precise and avoids the need for the Javadoc comment

/**
* The hunkChecksums for the diff.
*/
private final List hunkChecksums;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be List<HunkChecksum/String>

/**
* @return the hunkChecksums
*/
public List getHunkChecksums() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

}

@Override
public Action<Unit> insertDefaultGroup(PullRequestIdentifier pull, List<OrderingGroup> groups) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This method always gets called with a list of one group. You can eliminate the list and just make the argument an OrderingGroup

.on(InsertPullIfNotExists.class).returnA(pullRequestID)
.on(FetchGroupsForPull.class).returnA(List.empty())
.on(NewGroup.class).apply(action -> {
assertThat(action.defaultGroup).isEqualTo(true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This assertion is unnecessary.

@Override
public Action<Unit> insertDefaultGroup(PullRequestIdentifier pull, List<OrderingGroup> groups) {
return insertPullIfNotExists(pull)
.then(this::clearExistingGroups)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems unnecessary and dangerous 😅


Interpreter interpreter =
interpret()
.on(InsertPullIfNotExists.class).returnA(pullRequestID)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you remove this line, the test will fail if the insertion of a default group depends on existing groups. This would catch the unnecessary clearExistingGroups action in DatabaseService.

.on(AssignHunkToGroup.class).apply(toUnit(action -> {
assertThat(List.of(group).find(g -> g.id.equals(action.groupID))).isNotEmpty();
Option<HunkChecksum> hunkID = hunkIDs.find(id -> id.checksum.equals(action.hunkChecksum));
assertThat(hunkID).isNotEmpty();
Copy link
Collaborator

Choose a reason for hiding this comment

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

And while you're editing this file, please fix the indentation

@txsmith txsmith merged commit 3603bc2 into isApproved-v2 Jun 29, 2017
@txsmith txsmith deleted the import-groups branch June 29, 2017 09:15
eanker added a commit that referenced this pull request Jun 29, 2017
* Added initial version of approvingAPI v2

* Allow users to set the approval status multiple times

* Implement getApprovals

* Implement and test GitHub authentication actions (#53)

* Add tests for getApprovals actions

* Added two tests (then stepper was empty)

* Test that evaluation of getApproval finishes

* Added enpoint for fetching hunk approvals

* Added tests for getHunkApprovals

* Added javadoc for approvalsAPI

* Change all occurrences of Seq to List

* Implement DeleteGroup in DatabaseInterpreter

* Ensure ApproveStatus is never null

* Implement FetchHunksForGroup in DatabaseInterpreter

* Make Approvals refer to a hunk by their ID

* Constrain hunks to be unique per pull request

* Coerce the jOOQ api into handling 'INSERT INTO ... RETURNING ...' queries

* Change the database dsl to return entire hunks/approvals

* Fix tests for database service

* Re-implement hunk and approval fetching

* Implement generic deserialization of types with one field

* Implement wrapped type serialization

* Test wrapped type de/serialization

* Implement github authentication actions and a caching interpreter

* Import hunks when a PR is opened (#54)
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