Skip to content

Commit

Permalink
Filter private sponsors
Browse files Browse the repository at this point in the history
So far, I had no private sponsors at a level that would make them show
up in any list, so this wouldn't have made a difference. Now I do, so it
needs to be handled correctly.
  • Loading branch information
hannobraun committed Jan 12, 2024
1 parent c89c411 commit f352778
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tools/automator/src/sponsors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ impl Sponsors {
... on User {
login
sponsorshipForViewerAsSponsorable {
privacyLevel
createdAt
tier {
monthlyPriceInDollars
Expand All @@ -31,6 +32,7 @@ impl Sponsors {
... on Organization {
login
sponsorshipForViewerAsSponsorable {
privacyLevel
createdAt
tier {
monthlyPriceInDollars
Expand Down Expand Up @@ -63,6 +65,12 @@ impl Sponsors {
.nodes
.into_iter()
.filter_map(|node| {
if let QueryResultSponsorshipPrivacy::Private =
node.sponsorship_for_viewer_as_sponsorable.privacy_level
{
return None;
}

if node
.sponsorship_for_viewer_as_sponsorable
.is_one_time_payment
Expand Down Expand Up @@ -190,6 +198,9 @@ pub struct QueryResultSponsorsNode {

#[derive(Debug, serde::Deserialize)]
pub struct QueryResultSponsorable {
#[serde(rename = "privacyLevel")]
pub privacy_level: QueryResultSponsorshipPrivacy,

#[serde(rename = "createdAt")]
pub created_at: DateTime<Utc>,

Expand All @@ -199,6 +210,15 @@ pub struct QueryResultSponsorable {
pub is_one_time_payment: bool,
}

#[derive(Debug, serde::Deserialize)]
pub enum QueryResultSponsorshipPrivacy {
#[serde(rename = "PUBLIC")]
Public,

#[serde(rename = "PRIVATE")]
Private,
}

#[derive(Debug, serde::Deserialize)]
pub struct QueryResultSponsorableTier {
#[serde(rename = "monthlyPriceInDollars")]
Expand Down

0 comments on commit f352778

Please sign in to comment.