-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2712 from SwiftPackageIndex/fetch-funding
Fetch funding information and store in the database
- Loading branch information
Showing
10 changed files
with
164 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright Dave Verwer, Sven A. Schmidt, and other contributors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import Fluent | ||
|
||
|
||
struct AddFundingToRepositories: AsyncMigration { | ||
func prepare(on database: Database) async throws { | ||
try await database.schema("repositories") | ||
.field("funding_links", .array(of: .json), .sql(.default("{}"))) | ||
.update() | ||
} | ||
|
||
func revert(on database: Database) async throws { | ||
try await database.schema("repositories") | ||
.deleteField("funding_links") | ||
.update() | ||
} | ||
} |
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,73 @@ | ||
// Copyright Dave Verwer, Sven A. Schmidt, and other contributors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import Foundation | ||
|
||
|
||
struct FundingLink: Codable, Equatable { | ||
enum Platform: String, Codable { | ||
case communityBridge | ||
case customUrl | ||
case gitHub | ||
case issueHunt | ||
case koFi | ||
case lfxCrowdfunding | ||
case liberaPay | ||
case openCollective | ||
case otechie | ||
case patreon | ||
case tideLift | ||
} | ||
|
||
var platform: Platform | ||
var url: String | ||
} | ||
|
||
|
||
extension FundingLink { | ||
init(from node: Github.Metadata.FundingLinkNode) { | ||
platform = .init(from: node.platform) | ||
url = node.url | ||
} | ||
} | ||
|
||
|
||
extension FundingLink.Platform { | ||
init(from platform: Github.Metadata.FundingLinkNode.Platform) { | ||
switch platform { | ||
case .communityBridge: | ||
self = .communityBridge | ||
case .customUrl: | ||
self = .customUrl | ||
case .gitHub: | ||
self = .gitHub | ||
case .issueHunt: | ||
self = .issueHunt | ||
case .koFi: | ||
self = .koFi | ||
case .lfxCrowdfunding: | ||
self = .lfxCrowdfunding | ||
case .liberaPay: | ||
self = .liberaPay | ||
case .openCollective: | ||
self = .openCollective | ||
case .otechie: | ||
self = .otechie | ||
case .patreon: | ||
self = .patreon | ||
case .tideLift: | ||
self = .tideLift | ||
} | ||
} | ||
} |
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
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