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

Tech - Stocker searchable_by dans searches made et nettoyage des données dans search_made__appellations_code #2220

Merged
merged 1 commit into from
Sep 20, 2024
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
1 change: 1 addition & 0 deletions back/src/config/pg/kysely/model/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ interface SearchesMade extends WithAcquisition {
lon: number | null;
distance: number | null;
gps: string | null;
searchable_by: "jobSeekers" | "students" | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
searchable_by: "jobSeekers" | "students" | null;
searchable_by: EstablishmentSearchableByValue | null;

}

interface UsersAgencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { MigrationBuilder } from "node-pg-migrate";

export async function up(pgm: MigrationBuilder): Promise<void> {
pgm.createType("searchable_by", ["students", "jobSeekers"]);
pgm.addColumn("searches_made", {
searchable_by: { type: "searchable_by" },
});

await pgm.db.query(`
DELETE FROM searches_made__appellation_code where appellation_code is null;
`);
pgm.alterColumn("searches_made__appellation_code", "appellation_code", {
notNull: true,
});
}

export async function down(pgm: MigrationBuilder): Promise<void> {
pgm.dropColumn("searches_made", "searchable_by");
pgm.dropType("searchable_by");
pgm.alterColumn("searches_made__appellation_code", "appellation_code", {
notNull: false,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class PgSearchMadeRepository implements SearchMadeRepository {
public async insertSearchMade(searchMade: SearchMadeEntity) {
await this.#insertSearchMade(searchMade);

if (searchMade.appellationCodes) {
if (searchMade.appellationCodes && searchMade.appellationCodes.length > 0) {
await this.#insertAppellationCodes(
searchMade.id,
searchMade.appellationCodes,
Expand All @@ -34,6 +34,7 @@ export class PgSearchMadeRepository implements SearchMadeRepository {
sorted_by: searchMade.sortedBy,
address: searchMade.place,
number_of_results: searchMade.numberOfResults,
searchable_by: searchMade.establishmentSearchableBy,
acquisition_keyword: searchMade.acquisitionKeyword,
acquisition_campaign: searchMade.acquisitionCampaign,
...(hasSearchMadeGeoParams(searchMade)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class SearchImmersion extends TransactionalUseCase<
needsToBeSearched: true,
apiConsumerName: apiConsumer?.name,
numberOfResults:
voluntaryToImmersion !== false
voluntaryToImmersion !== false // cases where voluntaryToImmersion is undefined and true
? repositorySearchResults.length
: lbbSearchResults.length,
});
Expand Down
Loading