From fd6acd9e1ba676777ec5b15d37b2474bbee0e8c4 Mon Sep 17 00:00:00 2001 From: Doug Schrashun Date: Wed, 20 Nov 2024 09:22:20 -0500 Subject: [PATCH 1/4] fix typo in markup parse logic --- frontend/src/utils/generalUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/utils/generalUtils.ts b/frontend/src/utils/generalUtils.ts index 3f6e98277..5c7f795a2 100644 --- a/frontend/src/utils/generalUtils.ts +++ b/frontend/src/utils/generalUtils.ts @@ -31,8 +31,8 @@ export const splitMarkup = ( } // handle things like urls within tag params that need to be ignored if ( - (tracker.openTagIndicator && character === `"`) || - character === `'` + tracker.openTagIndicator && + (character === `"` || character === `'`) ) { tracker.inQuotes = !tracker.inQuotes; } From 3aba5e34cebd61889cb06fdeee73312caadf9456 Mon Sep 17 00:00:00 2001 From: Doug Schrashun Date: Wed, 20 Nov 2024 10:23:27 -0500 Subject: [PATCH 2/4] wip add seed --- api/tests/lib/seed_local_db.py | 4 ++++ api/tests/src/db/models/factories.py | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/api/tests/lib/seed_local_db.py b/api/tests/lib/seed_local_db.py index 1772b02af..71acf5581 100644 --- a/api/tests/lib/seed_local_db.py +++ b/api/tests/lib/seed_local_db.py @@ -102,6 +102,10 @@ def _build_opportunities(db_session: db.Session, iterations: int, include_histor size=2, is_posted_summary=True, has_long_descriptions=True ) + factories.OpportunityFactory.create_batch( + size=3, is_posted_summary=True, has_markup_descriptions=True + ) + if include_history: _add_history(forecasted_opps, add_forecast_hist=True) _add_history( diff --git a/api/tests/src/db/models/factories.py b/api/tests/src/db/models/factories.py index 05024951f..a7118f076 100644 --- a/api/tests/src/db/models/factories.py +++ b/api/tests/src/db/models/factories.py @@ -157,6 +157,8 @@ class CustomProvider(BaseProvider): "s3://local-opportunities/test_file_5.pdf", ] + MARKUP_STRING = "
{{paragraph}} {{sentence}} {{paragraph}}
{{paragraph}} {{sentence}} {{paragraph}}
" + def agency_code(self) -> str: return self.random_element(self.AGENCIES) @@ -201,6 +203,10 @@ def yn_yesno_boolean(self) -> str: def s3_file_location(self) -> str: return self.random_element(self.OPPORTUNITY_ATTACHMENT_S3_PATHS) + def complex_markup_string(self) -> str: + return self.generator.parse(self.MARKUP_STRING) + + fake = faker.Faker() fake.add_provider(CustomProvider) @@ -344,6 +350,10 @@ class Params: current_opportunity_summary__has_long_descriptions=True ) + has_markup_descriptions = factory.Trait( + current_opportunity_summary__has_markup_descriptions=True + ) + # Set all nullable fields to null all_fields_null = factory.Trait( agency_code=None, @@ -582,6 +592,10 @@ class Params: close_date_description=factory.Faker("paragraph", nb_sentences=30), ) + has_markup_descriptions = factory.Trait( + summary_description=factory.Faker("complex_markup_string"), + ) + class CurrentOpportunitySummaryFactory(BaseFactory): class Meta: @@ -623,6 +637,10 @@ class Params: opportunity_summary__has_long_descriptions=True, ) + has_markup_descriptions = factory.Trait( + opportunity_summary__has_markup_descriptions=True, + ) + class OpportunityAssistanceListingFactory(BaseFactory): class Meta: From b1b9b91a9fb2e3fb1722edfbe26d0dd7ca917370 Mon Sep 17 00:00:00 2001 From: Doug Schrashun Date: Wed, 20 Nov 2024 10:33:57 -0500 Subject: [PATCH 3/4] cleanup --- api/tests/src/db/models/factories.py | 1 - 1 file changed, 1 deletion(-) diff --git a/api/tests/src/db/models/factories.py b/api/tests/src/db/models/factories.py index a7118f076..945a8649d 100644 --- a/api/tests/src/db/models/factories.py +++ b/api/tests/src/db/models/factories.py @@ -207,7 +207,6 @@ def complex_markup_string(self) -> str: return self.generator.parse(self.MARKUP_STRING) - fake = faker.Faker() fake.add_provider(CustomProvider) factory.Faker.add_provider(CustomProvider) From 09fa6dbd3059fd35f388ec35de8c53c83008a7fc Mon Sep 17 00:00:00 2001 From: Doug Schrashun Date: Fri, 22 Nov 2024 16:43:00 -0500 Subject: [PATCH 4/4] rethink seeding strategy --- api/tests/lib/seed_local_db.py | 4 ---- api/tests/src/db/models/factories.py | 20 ++------------------ 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/api/tests/lib/seed_local_db.py b/api/tests/lib/seed_local_db.py index 71acf5581..1772b02af 100644 --- a/api/tests/lib/seed_local_db.py +++ b/api/tests/lib/seed_local_db.py @@ -102,10 +102,6 @@ def _build_opportunities(db_session: db.Session, iterations: int, include_histor size=2, is_posted_summary=True, has_long_descriptions=True ) - factories.OpportunityFactory.create_batch( - size=3, is_posted_summary=True, has_markup_descriptions=True - ) - if include_history: _add_history(forecasted_opps, add_forecast_hist=True) _add_history( diff --git a/api/tests/src/db/models/factories.py b/api/tests/src/db/models/factories.py index 945a8649d..ddb46b8d6 100644 --- a/api/tests/src/db/models/factories.py +++ b/api/tests/src/db/models/factories.py @@ -134,6 +134,7 @@ class CustomProvider(BaseProvider): "{{agency_code}} is looking to further investigate this topic. {{paragraph}}", "

{{paragraph}}


{{paragraph}}

", "The purpose of this Notice of Funding Opportunity (NOFO) is to support research into {{job}} and how we might {{catch_phrase}}.", + "
{{paragraph:long}} {{sentence}} {{paragraph:long}}
{{paragraph:long}} {{sentence}} {{paragraph:long}}
" ] # In the formatting, ? becomes a random letter, # becomes a random digit @@ -157,7 +158,6 @@ class CustomProvider(BaseProvider): "s3://local-opportunities/test_file_5.pdf", ] - MARKUP_STRING = "
{{paragraph}} {{sentence}} {{paragraph}}
{{paragraph}} {{sentence}} {{paragraph}}
" def agency_code(self) -> str: return self.random_element(self.AGENCIES) @@ -191,6 +191,7 @@ def opportunity_title(self) -> str: return self.generator.parse(pattern) def summary_description(self) -> str: + self.generator.set_arguments("long", { "nb_sentences": 25 }) pattern = self.random_element(self.SUMMARY_DESCRIPTION_FORMATS) return self.generator.parse(pattern) @@ -203,9 +204,6 @@ def yn_yesno_boolean(self) -> str: def s3_file_location(self) -> str: return self.random_element(self.OPPORTUNITY_ATTACHMENT_S3_PATHS) - def complex_markup_string(self) -> str: - return self.generator.parse(self.MARKUP_STRING) - fake = faker.Faker() fake.add_provider(CustomProvider) @@ -349,10 +347,6 @@ class Params: current_opportunity_summary__has_long_descriptions=True ) - has_markup_descriptions = factory.Trait( - current_opportunity_summary__has_markup_descriptions=True - ) - # Set all nullable fields to null all_fields_null = factory.Trait( agency_code=None, @@ -591,11 +585,6 @@ class Params: close_date_description=factory.Faker("paragraph", nb_sentences=30), ) - has_markup_descriptions = factory.Trait( - summary_description=factory.Faker("complex_markup_string"), - ) - - class CurrentOpportunitySummaryFactory(BaseFactory): class Meta: model = opportunity_models.CurrentOpportunitySummary @@ -636,11 +625,6 @@ class Params: opportunity_summary__has_long_descriptions=True, ) - has_markup_descriptions = factory.Trait( - opportunity_summary__has_markup_descriptions=True, - ) - - class OpportunityAssistanceListingFactory(BaseFactory): class Meta: model = opportunity_models.OpportunityAssistanceListing