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

feat: remove filter 'Prise de contact' #1093

Merged
merged 6 commits into from
Jan 23, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ function HousingDetailsCardMobilisation({ housing, campaigns }: Props) {
<LabelNext component="h3">Dernière mise à jour</LabelNext>
<Typography>{lastUpdate(housing)}</Typography>
</Grid>
<Grid xs={6}>
<LabelNext component="h3">Prise de contact</LabelNext>
<Typography>
{campaigns.length === 0
? 'Jamais contacté'
: `Contacté ${campaigns.length} fois`}
</Typography>
</Grid>
<Grid xs={6}>
<LabelNext component="h3">
Dispositifs ({housing.precisions?.length ?? 0})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
beneficiaryCountOptions,
buildingPeriodOptions,
cadastralClassificationOptions,
campaignsCountOptions,
dataFileYearsExcludedOptions,
dataFileYearsIncludedOptions,
energyConsumptionOptions,
Expand Down Expand Up @@ -200,12 +199,6 @@ function HousingFiltersBadges(props: HousingFiltersBadgesProps) {
onChange={(values) => onChange?.({ geoPerimetersExcluded: values })}
/>
)}
<FilterBadges
options={campaignsCountOptions}
values={filters.campaignsCounts}
small={small}
onChange={(values) => onChange?.({ campaignsCounts: values })}
/>
<FilterBadges
options={statusOptions()}
values={filters.statusList?.map(String)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
beneficiaryCountOptions,
buildingPeriodOptions,
cadastralClassificationOptions,
campaignsCountOptions,
dataFileYearsExcludedOptions,
dataFileYearsIncludedOptions,
energyConsumptionOptions,
Expand Down Expand Up @@ -242,17 +241,6 @@ function HousingListFiltersSidemenu(props: Props) {
/>
</Grid>
)}
<Grid component="article" mb={2} xs={12}>
<AppMultiSelect
label="Prise de contact"
options={campaignsCountOptions}
initialValues={filters.campaignsCounts}
onChange={(values) => {
onChangeFilters({ campaignsCounts: values }, 'Prise de contact');
posthog.capture('filtre-prise-de-contact');
}}
/>
</Grid>
</Accordion>
<Accordion
label={
Expand Down
8 changes: 0 additions & 8 deletions frontend/src/models/HousingFilters.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
BeneficiaryCount,
BuildingPeriod,
CampaignCount,
ENERGY_CONSUMPTION_VALUES,
EnergyConsumption,
HousingByBuilding,
Expand Down Expand Up @@ -72,13 +71,6 @@ export const ownerKindOptions: SelectOption<OwnerKind>[] =
label: OWNER_KIND_LABELS[value]
}));

export const campaignsCountOptions: SelectOption<CampaignCount>[] = [
{ value: '0', label: 'Dans aucune campagne en cours' },
{ value: '1', label: 'Déjà contacté 1 fois' },
{ value: '2', label: 'Déjà contacté 2 fois' },
{ value: 'gt2', label: 'Déjà contacté 3 fois et plus' }
];

export const statusOptions = (
statusExcluded?: HousingStatus[]
): SelectOption[] => [
Expand Down
1 change: 0 additions & 1 deletion server/src/models/HousingFiltersApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const validators = (property = 'filters'): ValidationChain[] => [
body(`${property}.ownershipKinds`).custom(isArrayOf(isString)).optional(),
body(`${property}.housingCounts`).custom(isArrayOf(isString)).optional(),
body(`${property}.vacancyRates`).custom(isArrayOf(isString)).optional(),
body(`${property}.campaignsCounts`).custom(isArrayOf(isString)).optional(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

body(`${property}.campaignIds`).custom(isArrayOf(isUUID)).optional(),
body(`${property}.ownerIds`).custom(isArrayOf(isUUID)).optional(),
body(`${property}.localities`).custom(isArrayOf(isString)).optional(),
Expand Down
24 changes: 0 additions & 24 deletions server/src/repositories/housingRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,32 +455,8 @@ function filteredQuery(opts: FilteredQueryOptions) {
`cardinality(${campaignsTable}.campaign_ids) = 0`
);
}
if (filters.campaignsCounts?.includes('current')) {
whereBuilder.orWhereRaw(
`cardinality(${campaignsTable}.campaign_ids) >= 1`
);
}
if (filters.campaignsCounts?.indexOf('1') !== -1) {
whereBuilder.orWhereRaw(
`cardinality(${campaignsTable}.campaign_ids)`,
1
);
}
if (filters.campaignsCounts?.indexOf('2') !== -1) {
whereBuilder.orWhereRaw(
`cardinality(${campaignsTable}.campaign_ids)`,
2
);
}
if (filters.campaignsCounts?.indexOf('gt3') !== -1) {
whereBuilder.orWhereRaw(
`cardinality(${campaignsTable}.campaign_ids) >= ?`,
3
);
}
});
}

if (filters.ownerIds?.length) {
queryBuilder.whereIn(`${ownerTable}.id`, filters.ownerIds);
}
Expand Down
Loading