Merge pull request #847 from RyanRory/fix-link-preview

Fix link preview
pull/854/head
Morgan Pretty 1 year ago committed by GitHub
commit c5a9c92a92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -34,7 +34,7 @@ public struct Interaction: Codable, Identifiable, Equatable, FetchableRecord, Mu
let linkPreview: TypedTableAlias<LinkPreview> = TypedTableAlias()
let halfResolution: Double = LinkPreview.timstampResolution
return "(\(interaction[.timestampMs]) BETWEEN (\(linkPreview[.timestamp]) - \(halfResolution)) AND (\(linkPreview[.timestamp]) + \(halfResolution)))"
return "(\(interaction[.timestampMs]) BETWEEN (\(linkPreview[.timestamp]) - \(halfResolution)) * 1000 AND (\(linkPreview[.timestamp]) + \(halfResolution)) * 1000)"
}()
public static let recipientStates = hasMany(RecipientState.self, using: RecipientState.interactionForeignKey)
@ -251,12 +251,11 @@ public struct Interaction: Codable, Identifiable, Equatable, FetchableRecord, Mu
public var linkPreview: QueryInterfaceRequest<LinkPreview> {
/// **Note:** This equation **MUST** match the `linkPreviewFilterLiteral` logic
let halfResolution: Double = LinkPreview.timstampResolution
let roundedTimestamp: Double = (round(((Double(timestampMs) / 1000) / 100000) - 0.5) * 100000)
return request(for: Interaction.linkPreview)
.filter(
(Interaction.Columns.timestampMs >= (LinkPreview.Columns.timestamp - halfResolution)) &&
(Interaction.Columns.timestampMs <= (LinkPreview.Columns.timestamp + halfResolution))
(timestampMs >= (LinkPreview.Columns.timestamp - halfResolution) * 1000) &&
(timestampMs <= (LinkPreview.Columns.timestamp + halfResolution) * 1000)
)
}

Loading…
Cancel
Save