Skip to content

Commit

Permalink
Merge pull request #98 from gertrude-app/revert-displayid
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredh159 authored Oct 4, 2024
2 parents 2f29174 + 77940cc commit 3eff51e
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 20 deletions.
1 change: 1 addition & 0 deletions api/Sources/Api/Configure/migrations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ extension Configure {
app.migrations.add(RemoveSoftDeletes())
app.migrations.add(RemoveUserTokenNullable())
app.migrations.add(ScreenshotDisplayId())
app.migrations.add(RevertScreenshotDisplayId())
}
}
10 changes: 10 additions & 0 deletions api/Sources/Api/Database/Migrations/027_ScreenshotDisplayId.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ struct ScreenshotDisplayId: GertieMigration {
}
}

struct RevertScreenshotDisplayId: GertieMigration {
func up(sql: SQLDatabase) async throws {
try await ScreenshotDisplayId().down(sql: sql)
}

func down(sql: SQLDatabase) async throws {
try await ScreenshotDisplayId().up(sql: sql)
}
}

extension Screenshot {
enum M27 {
static let displayId = FieldKey("display_id")
Expand Down
3 changes: 0 additions & 3 deletions api/Sources/Api/Models/Activity/Screenshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ struct Screenshot: Codable, Sendable {
var url: String
var width: Int
var height: Int
var displayId: Int?
var filterSuspended: Bool
var createdAt: Date
var deletedAt: Date?
Expand All @@ -17,7 +16,6 @@ struct Screenshot: Codable, Sendable {
url: String,
width: Int,
height: Int,
displayId: Int? = nil,
filterSuspended: Bool = false,
createdAt: Date = Date()
) {
Expand All @@ -26,7 +24,6 @@ struct Screenshot: Codable, Sendable {
self.url = url
self.width = width
self.height = height
self.displayId = displayId
self.filterSuspended = filterSuspended
self.createdAt = createdAt
}
Expand Down
1 change: 0 additions & 1 deletion api/Sources/Api/Models/Models+Duet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ extension Screenshot {
case url
case width
case height
case displayId
case filterSuspended
case createdAt
case deletedAt
Expand Down
2 changes: 0 additions & 2 deletions api/Sources/Api/Models/Models+DuetSQL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ extension Screenshot: Model {
case .url: .string(self.url)
case .width: .int(self.width)
case .height: .int(self.height)
case .displayId: .int(self.displayId)
case .filterSuspended: .bool(self.filterSuspended)
case .createdAt: .date(self.createdAt)
case .deletedAt: .date(self.deletedAt)
Expand All @@ -413,7 +412,6 @@ extension Screenshot: Model {
.url: .string(self.url),
.width: .int(self.width),
.height: .int(self.height),
.displayId: .int(self.displayId),
.filterSuspended: .bool(self.filterSuspended),
.createdAt: .date(self.createdAt),
.deletedAt: .date(self.deletedAt),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ extension CreateSignedScreenshotUpload: Resolver {
url: webUrlString,
width: input.width,
height: input.height,
displayId: input.displayId,
filterSuspended: input.filterSuspended ?? false,
createdAt: input.createdAt ?? get(dependency: \.date.now)
))
Expand Down
12 changes: 2 additions & 10 deletions api/Tests/ApiTests/MacappPairResolvers/MacAppResolverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ final class MacAppResolverTests: ApiTestCase {
expect(afterCount).toEqual(beforeCount + 1)
}

func testCreateSignedScreenshotUploadWithAllData() async throws {
func testCreateSignedScreenshotUploadWithDate() async throws {
let user = try await self.userWithDevice()
let uuids = MockUUIDs()

Expand All @@ -154,20 +154,12 @@ final class MacAppResolverTests: ApiTestCase {
$0.uuid = .mock(uuids)
} operation: {
_ = try await CreateSignedScreenshotUpload.resolve(
with: .init(
width: 1116,
height: 222,
displayId: 2,
filterSuspended: true,
createdAt: .epoch
),
with: .init(width: 1116, height: 222, createdAt: .epoch),
in: self.context(user)
)
let screenshot = try await self.db.find(Screenshot.Id(uuids[1]))
expect(screenshot.width).toEqual(1116)
expect(screenshot.createdAt).toEqual(.epoch)
expect(screenshot.displayId).toEqual(2)
expect(screenshot.filterSuspended).toEqual(true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,18 @@ public struct CreateSignedScreenshotUpload: Pair {
public struct Input: PairInput {
public let width: Int
public let height: Int
public let displayId: Int? // added v2.5.0, backwards compatible
public var filterSuspended: Bool?
public let createdAt: Date?

public init(
width: Int,
height: Int,
displayId: Int? = nil,
filterSuspended: Bool? = false,
createdAt: Date? = nil
) {
self.width = width
self.height = height
self.filterSuspended = filterSuspended
self.displayId = displayId
self.createdAt = createdAt
}
}
Expand Down

0 comments on commit 3eff51e

Please sign in to comment.