Skip to content

Commit

Permalink
Corrected the column definition for fundingLinks.
Browse files Browse the repository at this point in the history
  • Loading branch information
daveverwer committed Nov 14, 2023
1 parent d8396bc commit b8928f7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Sources/App/Migrations/070/AddFundingToRepositories.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Fluent
struct AddFundingToRepositories: AsyncMigration {
func prepare(on database: Database) async throws {
try await database.schema("repositories")
.field("funding_links", .json)
.field("funding_links", .array(of: .json), .sql(.default("{}")))
.update()
}

Expand Down
3 changes: 3 additions & 0 deletions Sources/App/Models/Repository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ final class Repository: Model, Content {
defaultBranch: String? = nil,
firstCommitDate: Date? = nil,
forks: Int = 0,
fundingLinks: [Github.FundingLink] = [],
forkedFrom: Repository? = nil,
homepageUrl: String? = nil,
isArchived: Bool = false,
Expand Down Expand Up @@ -166,6 +167,7 @@ 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 @@ -195,6 +197,7 @@ 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
10 changes: 0 additions & 10 deletions Tests/AppTests/Mocks/GithubMetadata+mock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ import Foundation
extension Github.Metadata {
static let mock: Self = .init(defaultBranch: "main",
forks: 1,
fundingLinks: [
.init(platform: .gitHub, url: "https://github.com/username1"),
.init(platform: .gitHub, url: "https://github.com/username2"),
.init(platform: .customUrl, url: "https://example.com/username")
],
homepageUrl: nil,
isInOrganization: false,
issuesClosedAtDates: [],
Expand All @@ -43,11 +38,6 @@ extension Github.Metadata {
let (owner, name) = try! Github.parseOwnerName(url: packageUrl)
return .init(defaultBranch: "main",
forks: packageUrl.count,
fundingLinks: [
.init(platform: .gitHub, url: "https://github.com/username1"),
.init(platform: .gitHub, url: "https://github.com/username2"),
.init(platform: .customUrl, url: "https://example.com/username")
],
homepageUrl: nil,
isInOrganization: false,
issuesClosedAtDates: [],
Expand Down

0 comments on commit b8928f7

Please sign in to comment.