Skip to content

Commit

Permalink
new fix and sync
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed May 19, 2016
1 parent 087e16c commit 7f1b26d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 34 deletions.
1 change: 0 additions & 1 deletion src/budy/bots/omni_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def __init__(self, *args, **kwargs):

def tick(self):
if not self.enabled: return
self.fix_products()
self.sync_products()
self.fix_products()

Expand Down
19 changes: 0 additions & 19 deletions src/budy/models/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ def quantity(self):
def fix_s(self):
if not self.exists(): return
self._fix_value_s()
self._fix_duplicates_s()
self._fix_invalid_s()

@appier.operation(name = "Duplicate Measurement")
def duplicate_s(self):
Expand All @@ -190,23 +188,6 @@ def _fix_value_s(self):
self.value = int(self.value)
self.save()

def _fix_duplicates_s(self):
cls = self.__class__
measurements = cls.find(
product = self.product.id,
name = self.name,
value = self.value
)
if len(measurements) == 1: return
for measurement in measurements[1:]:
measurement.delete()
parent = measurement.parent if hasattr(self, "parent") else None
if not parent: continue
exists = measurement in parent.measurements
if not exists: continue
parent.measurements.remove(measurement)
parent.save()

def _fix_invalid_s(self):
is_valid = hasattr(self, "parent") and not self.parent == None
if is_valid: return
Expand Down
14 changes: 0 additions & 14 deletions src/budy/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,20 +561,6 @@ def remove_image_s(self, image):
@appier.operation(name = "Fix Product")
def fix_s(self):
if not self.exists(): return

removal = []
for measurement in self.measurements:
is_valid = hasattr(measurement, "quantity")
if is_valid: continue
removal.append(measurement)

if not removal: return

for measurement in removal:
self.measurements.remove(measurement)
if not hasattr(measurement, "delete"): continue
measurement.delete()

self.save()

@property
Expand Down

0 comments on commit 7f1b26d

Please sign in to comment.