-
Notifications
You must be signed in to change notification settings - Fork 7
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 required information to DBP NA<->FE API for removal timeline support #3268
base: main
Are you sure you want to change the base?
Changes from 3 commits
1c82d0f
6388873
24d3fc9
19ba1c8
2f45004
9e326ef
fa5f675
59988dd
0865a78
9aa5b41
1af1ebe
29c8bb8
c2d4d9f
06b1020
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,36 +22,6 @@ import os.log | |
|
||
struct MapperToUI { | ||
|
||
func mapToUI(_ dataBroker: DataBroker, extractedProfile: ExtractedProfile) -> DBPUIDataBrokerProfileMatch { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All this has now moved into constructors on the individual UI objects |
||
DBPUIDataBrokerProfileMatch( | ||
dataBroker: mapToUI(dataBroker), | ||
name: extractedProfile.fullName ?? "No name", | ||
addresses: extractedProfile.addresses?.map(mapToUI) ?? [], | ||
alternativeNames: extractedProfile.alternativeNames ?? [String](), | ||
relatives: extractedProfile.relatives ?? [String](), | ||
date: extractedProfile.removedDate?.timeIntervalSince1970 | ||
) | ||
} | ||
|
||
func mapToUI(_ dataBrokerName: String, databrokerURL: String, extractedProfile: ExtractedProfile) -> DBPUIDataBrokerProfileMatch { | ||
DBPUIDataBrokerProfileMatch( | ||
dataBroker: DBPUIDataBroker(name: dataBrokerName, url: databrokerURL), | ||
name: extractedProfile.fullName ?? "No name", | ||
addresses: extractedProfile.addresses?.map(mapToUI) ?? [], | ||
alternativeNames: extractedProfile.alternativeNames ?? [String](), | ||
relatives: extractedProfile.relatives ?? [String](), | ||
date: extractedProfile.removedDate?.timeIntervalSince1970 | ||
) | ||
} | ||
|
||
func mapToUI(_ dataBroker: DataBroker) -> DBPUIDataBroker { | ||
DBPUIDataBroker(name: dataBroker.name, url: dataBroker.url) | ||
} | ||
|
||
func mapToUI(_ address: AddressCityState) -> DBPUIUserProfileAddress { | ||
DBPUIUserProfileAddress(street: address.fullAddress, city: address.city, state: address.state, zipCode: nil) | ||
} | ||
|
||
func initialScanState(_ brokerProfileQueryData: [BrokerProfileQueryData]) -> DBPUIInitialScanState { | ||
|
||
let withoutDeprecated = brokerProfileQueryData.filter { !$0.profileQuery.deprecated } | ||
|
@@ -82,13 +52,18 @@ struct MapperToUI { | |
private func mapMatchesToUI(_ brokerProfileQueryData: [BrokerProfileQueryData]) -> [DBPUIDataBrokerProfileMatch] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like how much this and the maintenance scans function duplicate each other. However I'm also afraid to touch them since there seem to be some subtle differences which I assume are deliberate |
||
return brokerProfileQueryData.flatMap { | ||
var profiles = [DBPUIDataBrokerProfileMatch]() | ||
for extractedProfile in $0.extractedProfiles where !$0.profileQuery.deprecated { | ||
profiles.append(mapToUI($0.dataBroker, extractedProfile: extractedProfile)) | ||
for (extractedProfile, optOutJobData) in $0.extractedProfilesWithOptOutJobData where !$0.profileQuery.deprecated { | ||
profiles.append(DBPUIDataBrokerProfileMatch(extractedProfile: extractedProfile, | ||
optOutJobData: optOutJobData, | ||
dataBroker: $0.dataBroker)) | ||
|
||
if !$0.dataBroker.mirrorSites.isEmpty { | ||
let mirrorSitesMatches = $0.dataBroker.mirrorSites.compactMap { mirrorSite in | ||
if mirrorSite.shouldWeIncludeMirrorSite() { | ||
return mapToUI(mirrorSite.name, databrokerURL: mirrorSite.url, extractedProfile: extractedProfile) | ||
return DBPUIDataBrokerProfileMatch(extractedProfile: extractedProfile, | ||
optOutJobData: optOutJobData, | ||
dataBrokerName: mirrorSite.name, | ||
databrokerURL: mirrorSite.url) | ||
} | ||
|
||
return nil | ||
|
@@ -113,7 +88,9 @@ struct MapperToUI { | |
let scanJob = $0.scanJobData | ||
for optOutJob in $0.optOutJobData { | ||
let extractedProfile = optOutJob.extractedProfile | ||
let profileMatch = mapToUI(dataBroker, extractedProfile: extractedProfile) | ||
let profileMatch = DBPUIDataBrokerProfileMatch(extractedProfile: extractedProfile, | ||
optOutJobData: optOutJob, | ||
dataBroker: dataBroker) | ||
|
||
if extractedProfile.removedDate == nil { | ||
inProgressOptOuts.append(profileMatch) | ||
|
@@ -123,7 +100,10 @@ struct MapperToUI { | |
|
||
if let closestMatchesFoundEvent = scanJob.closestMatchesFoundEvent() { | ||
for mirrorSite in dataBroker.mirrorSites where mirrorSite.shouldWeIncludeMirrorSite(for: closestMatchesFoundEvent.date) { | ||
let mirrorSiteMatch = mapToUI(mirrorSite.name, databrokerURL: mirrorSite.url, extractedProfile: extractedProfile) | ||
let mirrorSiteMatch = DBPUIDataBrokerProfileMatch(extractedProfile: extractedProfile, | ||
optOutJobData: optOutJob, | ||
dataBrokerName: mirrorSite.name, | ||
databrokerURL: mirrorSite.url) | ||
|
||
if let extractedProfileRemovedDate = extractedProfile.removedDate, | ||
mirrorSite.shouldWeIncludeMirrorSite(for: extractedProfileRemovedDate) { | ||
|
@@ -137,15 +117,9 @@ struct MapperToUI { | |
} | ||
|
||
let completedOptOutsDictionary = Dictionary(grouping: removedProfiles, by: { $0.dataBroker }) | ||
let completedOptOuts: [DBPUIOptOutMatch] = completedOptOutsDictionary.compactMap { (key: DBPUIDataBroker, value: [DBPUIDataBrokerProfileMatch]) in | ||
let completedOptOuts: [DBPUIOptOutMatch] = completedOptOutsDictionary.compactMap { (_, value: [DBPUIDataBrokerProfileMatch]) in | ||
value.compactMap { match in | ||
guard let removedDate = match.date else { return nil } | ||
return DBPUIOptOutMatch(dataBroker: key, | ||
matches: value.count, | ||
name: match.name, | ||
alternativeNames: match.alternativeNames, | ||
addresses: match.addresses, | ||
date: removedDate) | ||
return DBPUIOptOutMatch(profileMatch: match, matches: value.count) | ||
} | ||
}.flatMap { $0 } | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love that this information is gained from the optOutJobData, but what you can't see from looking just at this struct is if you see further above is that all these extracted profiles are taken from the opt out jobs the first place.
So I don't think there's anything I can do about it outside of making more serious challenges to our data architecture (which I'd love to do. In making this PR I really noticed how my issues with the DB scheme trickle all the way up to cause a lot of the things I don't like in the UI mapping stuff)