fix: update IDSData model and import function

The commit message is:

fix: update IDSData model and import function to handle decimal values in CSV data
This commit is contained in:
Lord_Devi 2024-09-16 23:14:49 -04:00
parent 01a8fc360e
commit 1cd1295202
2 changed files with 11 additions and 11 deletions

View file

@ -40,9 +40,9 @@ class IDSData(models.Model):
gbp_review_rating = models.FloatField(null=True, blank=True)
gbp_review_count = models.IntegerField(null=True, blank=True)
gbp_industry_avg_review_rating = models.FloatField(null=True, blank=True)
gbp_industry_avg_review_count = models.IntegerField(null=True, blank=True)
gbp_industry_avg_review_count = models.FloatField(null=True, blank=True)
gbp_review_rating_offset = models.FloatField(null=True, blank=True)
gbp_review_count_offset = models.IntegerField(null=True, blank=True)
gbp_review_count_offset = models.FloatField(null=True, blank=True)
gbp_review_rating_health = models.CharField(max_length=50, blank=True, null=True)
gbp_review_count_health = models.CharField(max_length=50, blank=True, null=True)
gbp_location_municipality = models.CharField(max_length=255)

View file

@ -78,12 +78,12 @@ def ids_data_import(request):
yib=row['YiB'],
gbp_business_category=row['GBP Business Category'],
gbp_matching_service=row['GBP Matching Service'],
gbp_review_rating=row.get('GBP Review Rating', None),
gbp_review_count=row.get('GBP Review Count', None),
gbp_industry_avg_review_rating=row.get('GBP Industry Avg Review Rating', None),
gbp_industry_avg_review_count=row.get('GBP Industry Avg Review Count', None),
gbp_review_rating_offset=row.get('GBP Review Rating Offset fr. Avg', None),
gbp_review_count_offset=row.get('GBP Review Count Offset fr. Avg', None),
gbp_review_rating=float(row['GBP Review Rating']) if row['GBP Review Rating'] else None,
gbp_review_count=int(float(row['GBP Review Count'])) if row['GBP Review Count'] else None,
gbp_industry_avg_review_rating=float(row['GBP Industry Avg Review Rating']) if row['GBP Industry Avg Review Rating'] else None,
gbp_industry_avg_review_count=float(row['GBP Industry Avg Review Count']) if row['GBP Industry Avg Review Count'] else None,
gbp_review_rating_offset=float(row['GBP Review Rating Offset fr. Avg']) if row['GBP Review Rating Offset fr. Avg'] else None,
gbp_review_count_offset=float(row['GBP Review Count Offset fr. Avg']) if row['GBP Review Count Offset fr. Avg'] else None,
gbp_review_rating_health=row['GBP Review Rating Health'],
gbp_review_count_health=row['GBP Review Count Health'],
gbp_location_municipality=row['GBP Location Municipality'],
@ -93,9 +93,9 @@ def ids_data_import(request):
gbp_business_website=row['GBP Business Website'],
root_domain=row['Root Domain'],
md5_for_scrape=row['MD5 for Scrape'],
services_reputation_management=row['Services: Reputation Management'] == 'True',
services_gbp_optimization=row['Services: GBP Optimization'] == 'True',
services_needs_website=row['Services: Needs Website'] == 'True'
services_reputation_management=row['Services: Reputation Management'] == 'Yes',
services_gbp_optimization=row['Services: GBP Optimization'] == 'Yes',
services_needs_website=row['Services: Needs Website'] == 'Yes'
)
imported_count += 1
except Exception as row_error: