-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Add missing sponsors as contributors
- Loading branch information
Showing
20 changed files
with
538 additions
and
113 deletions.
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
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
96 changes: 96 additions & 0 deletions
96
bot-github-core/src/main/java/org/commonhaus/automation/github/context/DataSponsorship.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package org.commonhaus.automation.github.context; | ||
|
||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import jakarta.json.JsonArray; | ||
import jakarta.json.JsonObject; | ||
|
||
import io.quarkus.logging.Log; | ||
import io.smallrye.graphql.client.Response; | ||
|
||
public class DataSponsorship extends DataCommonType { | ||
|
||
public final boolean isActive; | ||
public final Date createdAt; | ||
public final DataActor sponsorable; | ||
public final DataActor sponsorEntity; | ||
public final DataTier tier; | ||
|
||
DataSponsorship(JsonObject object) { | ||
super(object); | ||
|
||
// common with webhook | ||
this.createdAt = JsonAttribute.createdAt.dateFrom(object); | ||
this.sponsorable = JsonAttribute.sponsorable.actorFrom(object); | ||
this.sponsorEntity = JsonAttribute.sponsorEntity.actorFrom(object); | ||
this.tier = JsonAttribute.tier.tierFrom(object); | ||
|
||
// graphql only | ||
this.isActive = JsonAttribute.isActive.booleanFromOrFalse(object); | ||
} | ||
|
||
public String sponsorLogin() { | ||
return sponsorEntity.login; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DataSponsorship [isActive=" + isActive + ", sponsorable=" + sponsorable + ", sponsorEntity=" | ||
+ sponsorEntity + "]"; | ||
} | ||
|
||
public static List<DataSponsorship> queryRecentSponsors(QueryContext qc, String login) { | ||
if (qc.hasErrors()) { | ||
Log.debugf("[%s] queryRecentSponsors for sponsorable %s; skipping modify (errors)", qc.getLogId(), login); | ||
return null; | ||
} | ||
Log.debugf("[%s] queryRecentSponsors for sponsorable %s", qc.getLogId(), login); | ||
|
||
Map<String, Object> variables = new HashMap<>(); | ||
variables.put("login", login); | ||
Response response = qc.execQuerySync(""" | ||
query($login: String!) { | ||
organization(login: $login) { | ||
sponsorshipsAsMaintainer(first: 50, activeOnly: false, orderBy: {field: CREATED_AT, direction: DESC}) { | ||
totalCount | ||
nodes { | ||
isActive | ||
isOneTimePayment | ||
isActive | ||
isOneTimePayment | ||
sponsorEntity { | ||
... on User { | ||
login | ||
} | ||
... on Organization { | ||
login | ||
} | ||
} | ||
} | ||
pageInfo { | ||
hasNextPage | ||
endCursor | ||
} | ||
} | ||
} | ||
} | ||
""", variables); | ||
if (qc.hasErrors() || response == null) { | ||
return List.of(); | ||
} | ||
|
||
JsonObject organization = JsonAttribute.organization.jsonObjectFrom(response.getData()); | ||
JsonObject sponsorshipsAsMaintainer = JsonAttribute.sponsorshipsAsMaintainer.jsonObjectFrom(organization); | ||
JsonArray nodes = JsonAttribute.nodes.jsonArrayFrom(sponsorshipsAsMaintainer); | ||
if (nodes == null) { | ||
return List.of(); | ||
} | ||
return nodes.stream() | ||
.map(JsonObject.class::cast) | ||
.map(DataSponsorship::new) | ||
.toList(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
bot-github-core/src/main/java/org/commonhaus/automation/github/context/DataTier.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.commonhaus.automation.github.context; | ||
|
||
import java.util.Date; | ||
|
||
import jakarta.json.JsonObject; | ||
|
||
public class DataTier extends DataCommonType { | ||
|
||
static final String TIER_FIELDS = """ | ||
id | ||
name | ||
monthlyPriceInCents | ||
monthlyPriceInDollars | ||
isOneTime | ||
isCustomAmount | ||
"""; | ||
|
||
public final Date createdAt; | ||
public final Integer monthlyPriceInCents; | ||
public final Integer monthlyPriceInDollars; | ||
public final String name; | ||
public final boolean isOneTime; | ||
public final boolean isCustomAmount; | ||
|
||
DataTier(JsonObject object) { | ||
super(object); | ||
this.createdAt = JsonAttribute.createdAt.dateFrom(object); | ||
this.monthlyPriceInCents = JsonAttribute.monthlyPriceInCents.integerFrom(object); | ||
this.monthlyPriceInDollars = JsonAttribute.monthlyPriceInDollars.integerFrom(object); | ||
this.name = JsonAttribute.name.stringFrom(object); | ||
this.isOneTime = JsonAttribute.isOneTime.booleanFromOrFalse(object); | ||
this.isCustomAmount = JsonAttribute.isCustomAmount.booleanFromOrFalse(object); | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
cf-admin-bot/src/main/java/org/commonhaus/automation/admin/config/SponsorsConfig.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.commonhaus.automation.admin.config; | ||
|
||
import io.quarkus.runtime.annotations.RegisterForReflection; | ||
|
||
@RegisterForReflection | ||
public record SponsorsConfig( | ||
String sponsorable, | ||
String repository, | ||
Boolean dryRun) { | ||
public Boolean dryRun() { | ||
return dryRun != null && dryRun; | ||
} | ||
} |
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.