Skip to content

Commit

Permalink
Merge pull request #2719 from SwiftPackageIndex/revert-2712-fetch-fun…
Browse files Browse the repository at this point in the history
…ding
  • Loading branch information
daveverwer authored Nov 16, 2023
2 parents 90c5406 + 98b0786 commit 71b9b2c
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 164 deletions.
4 changes: 2 additions & 2 deletions Sources/App/Commands/Ingest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ func updateRepository(on database: Database,

repository.defaultBranch = repoMetadata.defaultBranch
repository.forks = repoMetadata.forkCount
repository.fundingLinks = repoMetadata.fundingLinks?.map(FundingLink.init(from:)) ?? []
repository.homepageUrl = repoMetadata.homepageUrl?.trimmed
repository.isArchived = repoMetadata.isArchived
repository.isInOrganization = repoMetadata.isInOrganization
Expand All @@ -217,7 +216,8 @@ func updateRepository(on database: Database,
repository.ownerAvatarUrl = repoMetadata.owner.avatarUrl
repository.s3Readme = s3Readme
repository.readmeHtmlUrl = readmeInfo?.htmlUrl
repository.releases = repoMetadata.releases.nodes.map(Release.init(from:))
repository.releases = metadata.repository?.releases.nodes
.map(Release.init(from:)) ?? []
repository.stars = repoMetadata.stargazerCount
repository.summary = repoMetadata.description

Expand Down
24 changes: 0 additions & 24 deletions Sources/App/Core/Github.swift
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,6 @@ extension Github {
}
description
forkCount
fundingLinks {
platform
url
}
homepageUrl
isArchived
isFork
Expand Down Expand Up @@ -342,7 +338,6 @@ extension Github {
var defaultBranchRef: DefaultBranchRef?
var description: String?
var forkCount: Int
var fundingLinks: [FundingLinkNode]?
var homepageUrl: String?
var isArchived: Bool
// periphery:ignore
Expand Down Expand Up @@ -370,25 +365,6 @@ extension Github {
}
}

struct FundingLinkNode: Codable, Equatable {
enum Platform: String, Codable {
case communityBridge = "COMMUNITY_BRIDGE"
case customUrl = "CUSTOM"
case gitHub = "GITHUB"
case issueHunt = "ISSUEHUNT"
case koFi = "KO_FI"
case lfxCrowdfunding = "LFX_CROWDFUNDING"
case liberaPay = "LIBERAPAY"
case openCollective = "OPEN_COLLECTIVE"
case otechie = "OTECHIE"
case patreon = "PATREON"
case tideLift = "TIDELIFT"
}

var platform: Platform
var url: String
}

struct IssueNodes: Decodable, Equatable {
var nodes: [IssueNode]

Expand Down
30 changes: 0 additions & 30 deletions Sources/App/Migrations/070/AddFundingToRepositories.swift

This file was deleted.

73 changes: 0 additions & 73 deletions Sources/App/Models/FundingLink.swift

This file was deleted.

6 changes: 0 additions & 6 deletions Sources/App/Models/Repository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ final class Repository: Model, Content {
@Field(key: "forks")
var forks: Int

@Field(key: "funding_links")
var fundingLinks: [FundingLink]

@Field(key: "homepage_url")
var homepageUrl: String?

Expand Down Expand Up @@ -134,7 +131,6 @@ final class Repository: Model, Content {
defaultBranch: String? = nil,
firstCommitDate: Date? = nil,
forks: Int = 0,
fundingLinks: [FundingLink] = [],
forkedFrom: Repository? = nil,
homepageUrl: String? = nil,
isArchived: Bool = false,
Expand Down Expand Up @@ -167,7 +163,6 @@ final class Repository: Model, Content {
if let forkId = forkedFrom?.id {
self.$forkedFrom.id = forkId
}
self.fundingLinks = fundingLinks
self.homepageUrl = homepageUrl
self.isArchived = isArchived
self.isInOrganization = isInOrganization
Expand Down Expand Up @@ -197,7 +192,6 @@ final class Repository: Model, Content {
self.defaultBranch = nil
self.firstCommitDate = nil
self.forks = 0
self.fundingLinks = []
self.homepageUrl = nil
self.isArchived = false
self.isInOrganization = false
Expand Down
3 changes: 0 additions & 3 deletions Sources/App/configure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,6 @@ public func configure(_ app: Application) throws -> String {
do { // Migration 069 - add builder_version to builds
app.migrations.add(UpdateBuildAddBuilderVersion())
}
do { // Migration 070 - Add `funding` JSON field to `repositories`
app.migrations.add(AddFundingToRepositories())
}

app.commands.use(Analyze.Command(), as: "analyze")
app.commands.use(CreateRestfileCommand(), as: "create-restfile")
Expand Down
10 changes: 0 additions & 10 deletions Tests/AppTests/Fixtures/github-graphql-resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -614,16 +614,6 @@
},
"description": "Elegant HTTP Networking in Swift",
"forkCount": 6727,
"fundingLinks": [
{
"platform": "GITHUB",
"url": "https://github.com/Alamofire"
},
{
"platform": "LFX_CROWDFUNDING",
"url": "https://crowdfunding.lfx.linuxfoundation.org/projects/alamofire"
}
],
"isArchived": false,
"isFork": false,
"licenseInfo": {
Expand Down
4 changes: 0 additions & 4 deletions Tests/AppTests/GithubTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ class GithubTests: AppTestCase {
XCTAssertEqual(res.repository?.closedPullRequests.nodes.first!.closedAt,
iso8601.date(from: "2021-05-28T15:50:17Z"))
XCTAssertEqual(res.repository?.forkCount, 6727)
XCTAssertEqual(res.repository?.fundingLinks, [
.init(platform: .gitHub, url: "https://github.com/Alamofire"),
.init(platform: .lfxCrowdfunding, url: "https://crowdfunding.lfx.linuxfoundation.org/projects/alamofire"),
])
XCTAssertEqual(res.repository?.mergedPullRequests.nodes.first!.closedAt,
iso8601.date(from: "2021-06-07T22:47:01Z"))
XCTAssertEqual(res.repository?.name, "Alamofire")
Expand Down
10 changes: 0 additions & 10 deletions Tests/AppTests/IngestorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ class IngestorTests: AppTestCase {
let repo = Repository(packageId: try pkg.requireID())
let md: Github.Metadata = .init(defaultBranch: "main",
forks: 1,
fundingLinks: [
.init(platform: .gitHub, url: "https://github.com/username"),
.init(platform: .customUrl, url: "https://example.com/username1"),
.init(platform: .customUrl, url: "https://example.com/username2")
],
homepageUrl: "https://swiftpackageindex.com/Alamofire/Alamofire",
isInOrganization: true,
issuesClosedAtDates: [
Expand Down Expand Up @@ -158,11 +153,6 @@ class IngestorTests: AppTestCase {
let repo = try await Repository.query(on: app.db).first().unwrap()
XCTAssertEqual(repo.defaultBranch, "main")
XCTAssertEqual(repo.forks, 1)
XCTAssertEqual(repo.fundingLinks, [
.init(platform: .gitHub, url: "https://github.com/username"),
.init(platform: .customUrl, url: "https://example.com/username1"),
.init(platform: .customUrl, url: "https://example.com/username2")
])
XCTAssertEqual(repo.homepageUrl, "https://swiftpackageindex.com/Alamofire/Alamofire")
XCTAssertEqual(repo.isInOrganization, true)
XCTAssertEqual(repo.keywords, ["bar", "baz", "foo"])
Expand Down
2 changes: 0 additions & 2 deletions Tests/AppTests/Mocks/GithubMetadata+mock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ extension Github.Metadata {

init(defaultBranch: String,
forks: Int,
fundingLinks: [FundingLinkNode] = [],
homepageUrl: String?,
isInOrganization: Bool,
issuesClosedAtDates: [Date],
Expand All @@ -82,7 +81,6 @@ extension Github.Metadata {
defaultBranchRef: .init(name: defaultBranch),
description: summary,
forkCount: forks,
fundingLinks: fundingLinks,
homepageUrl: homepageUrl,
isArchived: false,
isFork: false,
Expand Down

0 comments on commit 71b9b2c

Please sign in to comment.