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