Skip to content

Commit

Permalink
Disable custom data source mapping for now
Browse files Browse the repository at this point in the history
  • Loading branch information
janbaykara committed Mar 12, 2024
1 parent c12eb2a commit 6e17032
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
24 changes: 13 additions & 11 deletions hub/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,17 +1057,19 @@ async def map_one(self, member: Union[str, dict], loaders: Loaders) -> MappedMem
if postcode_data is not None:
update_fields[destination_column] = get(postcode_data, source_path)
else:
print("Custom enrichment layer requested", source, source_path, destination_column)
update_value = await loaders['source_loaders'][source].load(
self.EnrichmentLookup(
member_id=self.get_record_id(member),
postcode_data=postcode_data,
source_id=source,
source_path=source_path
)
)
print("Custom mapping", source, source_path, update_value)
update_fields[destination_column] = get(update_value['source_data'], source_path)
pass
# TODO: fix this — there's an async error when making Django requests inside the source_loader DataLoaders — then re-enable.
# print("Custom enrichment layer requested", source, source_path, destination_column)
# update_value = await loaders['source_loaders'][source].load(
# self.EnrichmentLookup(
# member_id=self.get_record_id(member),
# postcode_data=postcode_data,
# source_id=source,
# source_path=source_path
# )
# )
# print("Custom mapping", source, source_path, update_value)
# update_fields[destination_column] = get(update_value['source_data'], source_path)
# Return the member and config data
return self.MappedMember(
member=member,
Expand Down
36 changes: 21 additions & 15 deletions nextjs/src/components/UpdateMappingForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
SelectValue,
} from "@/components/ui/select"
import { gql, useQuery } from "@apollo/client";
import { useMemo } from "react";

const ENRICHMENT_LAYERS = gql`
query EnrichmentLayers {
Expand Down Expand Up @@ -67,7 +68,25 @@ export function UpdateMappingForm({
},
);

const customEnrichmentLayers = useQuery<EnrichmentLayersQuery>(ENRICHMENT_LAYERS)
// TODO: Fix source_loader code in API, then re-enable this
// const customEnrichmentLayers = useQuery<EnrichmentLayersQuery>(ENRICHMENT_LAYERS)
// const sources: EnrichmentDataSource[] = useMemo(() => {
// return enrichmentDataSources.concat(
// customEnrichmentLayers.data?.externalDataSources
// .filter(source => !!source.geographyColumn)
// .map((source) => ({
// slug: source.id,
// name: source.name,
// author: "",
// description: "",
// descriptionURL: "",
// colour: "",
// builtIn: false,
// sourcePaths: source.fieldDefinitions || []
// })) || []
// )
// }, [enrichmentDataSources, customEnrichmentLayers.data?.externalDataSources])
const sources = enrichmentDataSources

return (
<FormProvider {...form}>
Expand Down Expand Up @@ -135,20 +154,7 @@ export function UpdateMappingForm({
</Button>
<SourcePathSelector
focusOnMount={form.watch(`updateMapping.${index}.source`) === "?"}
sources={enrichmentDataSources.concat(
customEnrichmentLayers.data?.externalDataSources
.filter(source => !!source.geographyColumn)
.map((source) => ({
slug: source.id,
name: source.name,
author: "",
description: "",
descriptionURL: "",
colour: "",
builtIn: false,
sourcePaths: source.fieldDefinitions || []
})) || []
)}
sources={sources}
value={{
source: form.watch(`updateMapping.${index}.source`),
sourcePath: form.watch(`updateMapping.${index}.sourcePath`),
Expand Down

0 comments on commit 6e17032

Please sign in to comment.