<commit_before>"""
For CommonsCloud copyright information please see the LICENSE document
(the "License") included with this software package. This file may not
be used in any manner except in compliance with the License

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from flask import current_app
from flask import render_template

from CommonsCloudAPI.extensions import db
from CommonsCloudAPI.extensions import logger

from flask.ext.mail import Message


"""
This defines our basic Role model, we have to have this becasue of the
Flask-Security module. If you remove it Flask-Security gets fussy.
"""
class Notification(db.Model):

  __tablename__ = 'notification'
  __table_args__ = {
    'extend_existing': True
  }

  id = db.Column(db.Integer, primary_key=True)
  trigger = db.Column(db.String(255))


class Condition(db.Model):

  __tablename__ = 'condition'
  __table_args__ = {
    'extend_existing': True
  }

  id = db.Column(db.Integer, primary_key=True)
  condition = db.Column(db.String(255))


class Action(db.Model):

  __tablename__ = 'action'
  __table_args__ = {
    'extend_existing': True
  }

  id = db.Column(db.Integer, primary_key=True)
  action = db.Column(db.String(255)) # send_notification_email, etc. An actual python method would be preferrable


def execute_notification(signal_type, app, **data):

  if not 'type_2c1bd72acccf416aada3a6824731acc9' in data.storage:
    return {}

  logger.debug('Notification Executed from %s, with %s containing data %s', signal_type, app, dir(data))

  # @todo
  #
  # 1. Look through the Notification table's `trigger` column for the
  #    `signal_type` that we've identified above<commit_msg>Adding condititions;<commit_after>"""
For CommonsCloud copyright information please see the LICENSE document
(the "License") included with this software package. This file may not
be used in any manner except in compliance with the License

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from flask import current_app
from flask import render_template

from CommonsCloudAPI.extensions import db
from CommonsCloudAPI.extensions import logger

from flask.ext.mail import Message


"""
This defines our basic Role model, we have to have this becasue of the
Flask-Security module. If you remove it Flask-Security gets fussy.
"""
class Notification(db.Model):

  __tablename__ = 'notification'
  __table_args__ = {
    'extend_existing': True
  }

  id = db.Column(db.Integer, primary_key=True)
  trigger = db.Column(db.String(255))


class Condition(db.Model):

  __tablename__ = 'condition'
  __table_args__ = {
    'extend_existing': True
  }

  id = db.Column(db.Integer, primary_key=True)
  condition = db.Column(db.String(255))


class Action(db.Model):

  __tablename__ = 'action'
  __table_args__ = {
    'extend_existing': True
  }

  id = db.Column(db.Integer, primary_key=True)
  action = db.Column(db.String(255)) # send_notification_email, etc. An actual python method would be preferrable


def execute_notification(signal_type, app, **data):

  if  data.storage != 'type_2c1bd72acccf416aada3a6824731acc9':
    logger.debug('No notification present for this condition')
    return {}

  logger.debug('Notification Executed from %s, with %s containing data %s', signal_type, app, dir(data))

  # @todo
  #
  # 1. Look through the Notification table's `trigger` column for the
  #    `signal_type` that we've identified above
{'fraction_non_alphanumeric': 0.08305732484076433, 'fraction_numerical': 0.013248407643312102, 'mean_word_length': 4.61659513590844, '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': '1985065', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1121, 'n_words': 414}