<commit_before>from potnanny.extensions import db
from potnanny.apps.measurement.models import Measurement
from potnanny.apps.outlet.models import Outlet
from potnanny.apps.messenger.models import Messenger
from potnanny.apps.sensor.models import Sensor
from potnanny.apps.vesync.models import VesyncManager
import datetime
import re


class Action(db.Model):
    __tablename__ = 'actions'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(24), nullable=False)
    measurement_type = db.Column(db.String(24), nullable=False)
    sensor_address = db.Column(db.String(24), nullable=False, unique=True)
    outlet_id = db.Column(db.String(128), nullable=True)
    action_type = db.Column(db.String(24), nullable=False, server_default='sms-message')
    sms_recipient = db.Column(db.String(24), nullable=True)
    
    """
    Here, the 'on' columns are also used to store one time sms-message 
    conditions as well, if the action-type is sms-message and not switch-outlet.
    """
    on_condition = db.Column(db.String(16), nullable=True)
    on_threshold = db.Column(db.Integer, nullable=True)

    off_condition = db.Column(db.String(16), nullable=True)
    off_threshold = db.Column(db.Integer, nullable=True)

    wait_minutes = db.Column(db.Integer, nullable=False, server_default='10')
    active = db.Column(db.Boolean(), nullable=False, server_default='1')
    

    def __init__(self, name, mid, oid, addr, atype):
        self.name = name
        self.measurement_type = mid
        self.outlet_id = oid
        self.sensor_address = addr
        self.action_type = atype<commit_msg>removed unique constraint from Action object model for sensor_address<commit_after>from potnanny.extensions import db
from potnanny.apps.measurement.models import Measurement
from potnanny.apps.outlet.models import Outlet
from potnanny.apps.messenger.models import Messenger
from potnanny.apps.sensor.models import Sensor
from potnanny.apps.vesync.models import VesyncManager
import datetime
import re


class Action(db.Model):
    __tablename__ = 'actions'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(24), nullable=False)
    measurement_type = db.Column(db.String(24), nullable=False)
    sensor_address = db.Column(db.String(24), nullable=False)
    outlet_id = db.Column(db.String(128), nullable=True)
    action_type = db.Column(db.String(24), nullable=False, server_default='sms-message')
    sms_recipient = db.Column(db.String(24), nullable=True)
    
    """
    Here, the 'on' columns are also used to store one time sms-message 
    conditions as well, if the action-type is sms-message and not switch-outlet.
    """
    on_condition = db.Column(db.String(16), nullable=True)
    on_threshold = db.Column(db.Integer, nullable=True)

    off_condition = db.Column(db.String(16), nullable=True)
    off_threshold = db.Column(db.Integer, nullable=True)

    wait_minutes = db.Column(db.Integer, nullable=False, server_default='10')
    active = db.Column(db.Boolean(), nullable=False, server_default='1')
    

    def __init__(self, name, mid, oid, addr, atype):
        self.name = name
        self.measurement_type = mid
        self.outlet_id = oid
        self.sensor_address = addr
        self.action_type = atype
{'fraction_non_alphanumeric': 0.11067193675889328, 'fraction_numerical': 0.012161751292186074, 'mean_word_length': 4.061538461538461, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4714644', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1051, 'n_words': 236}