Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new exif metadata: software, film, chemistry #135

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Sources/VernissageServer/Application+Configure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ extension Application {
self.migrations.add(Exif.AddFilmColumn())
self.migrations.add(User.AddUrl())
self.migrations.add(Exif.AddGpsCoordinates())
self.migrations.add(Exif.AddSoftware())

try await self.autoMigrate()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,10 @@ struct AttachmentsController {
exif.fNumber = temporaryAttachmentDto.fNumber
exif.exposureTime = temporaryAttachmentDto.exposureTime
exif.photographicSensitivity = temporaryAttachmentDto.photographicSensitivity
exif.software = temporaryAttachmentDto.software
exif.film = temporaryAttachmentDto.film
exif.chemistry = temporaryAttachmentDto.chemistry
exif.scanner = temporaryAttachmentDto.scanner
exif.latitude = temporaryAttachmentDto.latitude
exif.longitude = temporaryAttachmentDto.longitude

Expand All @@ -336,7 +339,10 @@ struct AttachmentsController {
exif.fNumber = temporaryAttachmentDto.fNumber
exif.exposureTime = temporaryAttachmentDto.exposureTime
exif.photographicSensitivity = temporaryAttachmentDto.photographicSensitivity
exif.software = temporaryAttachmentDto.software
exif.film = temporaryAttachmentDto.film
exif.chemistry = temporaryAttachmentDto.chemistry
exif.scanner = temporaryAttachmentDto.scanner
exif.latitude = temporaryAttachmentDto.latitude
exif.longitude = temporaryAttachmentDto.longitude

Expand Down
9 changes: 9 additions & 0 deletions Sources/VernissageServer/DataTransferObjects/ExifDto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ struct ExifDto {
var fNumber: String?
var exposureTime: String?
var photographicSensitivity: String?
var software: String?
var film: String?
var chemistry: String?
var scanner: String?
var latitude: String?
var longitude: String?
}
Expand All @@ -34,7 +37,10 @@ extension ExifDto {
fNumber: exif.fNumber,
exposureTime: exif.exposureTime,
photographicSensitivity: exif.photographicSensitivity,
software: exif.software,
film: exif.film,
chemistry: exif.chemistry,
scanner: exif.scanner,
latitude: exif.latitude,
longitude: exif.longitude)
}
Expand All @@ -52,7 +58,10 @@ extension ExifDto {
fNumber != nil ||
exposureTime != nil ||
photographicSensitivity != nil ||
software != nil ||
film != nil ||
chemistry != nil ||
scanner != nil ||
latitude != nil ||
longitude != nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ struct TemporaryAttachmentDto {
var fNumber: String?
var exposureTime: String?
var photographicSensitivity: String?
var software: String?
var film: String?
var chemistry: String?
var scanner: String?
var locationId: String?
var licenseId: String?
var latitude: String?
Expand Down Expand Up @@ -49,7 +52,10 @@ extension TemporaryAttachmentDto: Validatable {
validations.add("fNumber", as: String?.self, is: .count(...50) || .nil, required: false)
validations.add("exposureTime", as: String?.self, is: .count(...50) || .nil, required: false)
validations.add("photographicSensitivity", as: String?.self, is: .count(...50) || .nil, required: false)
validations.add("software", as: String?.self, is: .count(...50) || .nil, required: false)
validations.add("film", as: String?.self, is: .count(...50) || .nil, required: false)
validations.add("chemistry", as: String?.self, is: .count(...50) || .nil, required: false)
validations.add("scanner", as: String?.self, is: .count(...50) || .nil, required: false)
validations.add("latitude", as: String?.self, is: .count(...50) || .nil, required: false)
validations.add("longitude", as: String?.self, is: .count(...50) || .nil, required: false)
}
Expand All @@ -65,7 +71,10 @@ extension TemporaryAttachmentDto {
fNumber != nil ||
exposureTime != nil ||
photographicSensitivity != nil ||
software != nil ||
film != nil ||
chemistry != nil ||
scanner != nil ||
latitude != nil ||
longitude != nil
}
Expand Down
36 changes: 36 additions & 0 deletions Sources/VernissageServer/Migrations/CreateExif.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,40 @@ extension Exif {
.update()
}
}

struct AddSoftware: AsyncMigration {
func prepare(on database: Database) async throws {
try await database
.schema(Exif.schema)
.field("software", .varchar(50))
.update()

try await database
.schema(Exif.schema)
.field("chemistry", .varchar(50))
.update()

try await database
.schema(Exif.schema)
.field("scanner", .varchar(50))
.update()
}

func revert(on database: Database) async throws {
try await database
.schema(Exif.schema)
.deleteField("software")
.update()

try await database
.schema(Exif.schema)
.deleteField("chemistry")
.update()

try await database
.schema(Exif.schema)
.deleteField("scanner")
.update()
}
}
}
9 changes: 9 additions & 0 deletions Sources/VernissageServer/Models/Exif.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,18 @@ final class Exif: Model, @unchecked Sendable {
@Field(key: "photographicSensitivity")
var photographicSensitivity: String?

@Field(key: "software")
var software: String?

@Field(key: "film")
var film: String?

@Field(key: "chemistry")
var chemistry: String?

@Field(key: "scanner")
var scanner: String?

@Field(key: "latitude")
var latitude: String?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ extension ControllersTests {
fNumber: "f/1.8",
exposureTime: "1/250",
photographicSensitivity: "2000",
software: "Capture One",
film: "Kodak 400",
chemistry: "SilverChem",
scanner: "Adobe Scanner",
locationId: location.stringId(),
licenseId: license?.stringId(),
latitude: "50,67211",
Expand Down Expand Up @@ -96,7 +99,10 @@ extension ControllersTests {
#expect(attachmentExif.fNumber == temporaryAttachmentDto.fNumber, "Attachment fNumber should be correct.")
#expect(attachmentExif.exposureTime == temporaryAttachmentDto.exposureTime, "Attachment exposureTime should be correct.")
#expect(attachmentExif.photographicSensitivity == temporaryAttachmentDto.photographicSensitivity, "Attachment photographicSensitivity should be correct.")
#expect(attachmentExif.software == temporaryAttachmentDto.software, "Attachment software should be correct.")
#expect(attachmentExif.film == temporaryAttachmentDto.film, "Attachment film should be correct.")
#expect(attachmentExif.chemistry == temporaryAttachmentDto.chemistry, "Attachment chemistry should be correct.")
#expect(attachmentExif.scanner == temporaryAttachmentDto.scanner, "Attachment scanner should be correct.")
#expect(attachmentExif.latitude == temporaryAttachmentDto.latitude, "Attachment film should be correct.")
#expect(attachmentExif.longitude == temporaryAttachmentDto.longitude, "Attachment film should be correct.")

Expand Down