Skip to content

Commit

Permalink
Revert "Add max weight (#14)"
Browse files Browse the repository at this point in the history
This reverts commit d3ab4c3.
  • Loading branch information
natedanner authored Apr 25, 2023
1 parent 8f31154 commit 9ff81f3
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 21 deletions.
2 changes: 0 additions & 2 deletions src/main/java/io/moderne/organizations/DgsConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public static class QUERY {

public static class ORGANIZATIONS_INPUT_ARGUMENT {
public static final String Repository = "repository";

public static final String Weight = "weight";
}

public static class USERORGANIZATIONS_INPUT_ARGUMENT {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import io.moderne.organizations.types.RepositoryInput;
import io.moderne.organizations.types.User;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.internal.lang.Nullable;
import reactor.core.publisher.Flux;

import java.io.IOException;
Expand All @@ -36,11 +35,10 @@ public OrganizationDataFetcher(ObjectMapper mapper) throws IOException {
}

@DgsQuery
Flux<Organization> organizations(@InputArgument RepositoryInput repository,
@InputArgument @Nullable Integer weight) {
Flux<Organization> organizations(@InputArgument RepositoryInput repository) {
return Flux.fromIterable(ownership)
.concatWith(Flux.fromIterable(ownershipJonathanLeitschuh))
.filter(org -> org.matches(repository) && (org.maxWeight() == null || weight == null || org.maxWeight() >= weight))
.filter(org -> org.matches(repository))
.map(OrganizationDataFetcher::mapOrganization)
.concatWithValues(Organization.newBuilder().id("ALL").name("ALL").commitOptions(List.of(CommitOption.values())).build()); // if you want an "ALL" group
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
* @param name The name of the organization
* @param repositories The set of repositories that this organization owns.
*/
public record OrganizationRepositories(String name,
@Nullable Long maxWeight,
List<OrganizationRepository> repositories,
public record OrganizationRepositories(String name, List<OrganizationRepository> repositories,
@Nullable List<CommitOption> commitOptions) {

boolean matches(RepositoryInput toMatchRepositoryInput) {
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/ownership.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[
{
"name": "Default",
"maxWeight": 700000,
"repositories": [
{
"origin": "github.com",
Expand Down
6 changes: 1 addition & 5 deletions src/main/resources/schema/moderne-organizations.graphqls
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
type Query {
"""
The list of organizations that a repository belongs to.
Weight is nullable only temporarily for backwards compatibility. When it becomes non-nullable,
it may or may not be used to determine organization ownership, but will always be available for that
purpose.
"""
organizations(repository: RepositoryInput!, weight: Int): [Organization!]!
organizations(repository: RepositoryInput!): [Organization!]!

"""
The list of organizations that a user belongs to. If it is possible to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ public class OrganizationDataFetcherTest {
@Test
void organizationForThisRepository() {
StepVerifier
.create(
organizationDataFetcher.organizations(
new RepositoryInput("moderneinc/moderne-organizations", "github.com", "main"),
10000
)
)
.create(organizationDataFetcher.organizations(new RepositoryInput("moderneinc/moderne-organizations", "github.com", "main")))
.expectNext(
Organization.newBuilder()
.id("Moderne")
Expand Down

0 comments on commit 9ff81f3

Please sign in to comment.