-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1877 from SEED-platform/labels-to-views
Labels to views
- Loading branch information
Showing
22 changed files
with
271 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
Data Quality | ||
============ | ||
|
||
Data quality checks are run after the data are paired or on-demand by selecting rows in the inventory | ||
page and clicking the action button. | ||
Data quality checks are run after the data are paired, during import of Properties/TaxLots, or on-demand by selecting rows in the inventory | ||
page and clicking the action button. This checks whether any default or user-defined Rules are broken or satisfied by Property/TaxLot records. | ||
|
||
Notably, in most cases when data quality checks are run, Labels can be applied for any broken Rules that have a Label. | ||
To elaborate, Rules can have an attached Label. When a data quality check is run, records that break one of these "Labeled Rules" | ||
are then given that Label. The case where this Label attachment does not happen is during import due to performance reasons. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.20 on 2019-05-09 01:54 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def reassociate_labels_to_views(apps, schema_editor): | ||
db_alias = schema_editor.connection.alias | ||
|
||
PropertyView = apps.get_model('seed', 'PropertyView') | ||
ThroughModel = PropertyView.labels.through | ||
records = [] | ||
property_views = PropertyView.objects.using(db_alias).all()\ | ||
.select_related('property').prefetch_related('property__labels') | ||
for p_view in property_views: | ||
for label in p_view.property.labels.all(): | ||
records.append(ThroughModel(propertyview=p_view, statuslabel=label)) | ||
ThroughModel.objects.bulk_create(records) | ||
# Free memory | ||
del property_views | ||
|
||
TaxLotView = apps.get_model('seed', 'TaxLotView') | ||
ThroughModel = TaxLotView.labels.through | ||
records = [] | ||
taxlot_views = TaxLotView.objects.using(db_alias).all()\ | ||
.select_related('taxlot').prefetch_related('taxlot__labels') | ||
for tl_view in taxlot_views: | ||
for label in tl_view.taxlot.labels.all(): | ||
records.append(ThroughModel(taxlotview=tl_view, statuslabel=label)) | ||
ThroughModel.objects.bulk_create(records) | ||
# Free memory | ||
del taxlot_views | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('seed', '0103_auto_20190505_0731'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='propertyview', | ||
name='labels', | ||
field=models.ManyToManyField(to='seed.StatusLabel'), | ||
), | ||
migrations.AddField( | ||
model_name='taxlotview', | ||
name='labels', | ||
field=models.ManyToManyField(to='seed.StatusLabel'), | ||
), | ||
migrations.RunPython(reassociate_labels_to_views), | ||
migrations.RemoveField( | ||
model_name='taxlot', | ||
name='labels', | ||
), | ||
migrations.RemoveField( | ||
model_name='property', | ||
name='labels', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.