Exemple #1
0
class EnergyEvent(db.Model):
    __tablename__ = 'energy_events'
    id = db.Column(db.Integer, primary_key=True)
    energy_account_id = db.Column(db.Integer,
                                  db.ForeignKey('energy_accounts.id'))
    date = db.Column(db.Date)
    event_type = db.Column(db.Integer)
    info = db.Column(db.String(355))
Exemple #2
0
class AppEvent(db.Model):
    __tablename__ = 'app_events'
    id = db.Column(db.Integer, primary_key=True)
    date_time = db.Column(db.DateTime)
    event_type = db.Column(db.Integer)
    level = db.Column(db.Integer)
    info = db.Column(db.String(1300))
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
Exemple #3
0
class CeleryTask(db.Model):
    __tablename__ = 'celery_tasks'
    id = db.Column(db.Integer, primary_key=True)
    energy_account_id = db.Column(db.Integer,
                                  db.ForeignKey('energy_accounts.id'))
    task_id = db.Column(db.String(50))
    task_status = db.Column(db.Integer)

    def __repr__(self):
        return '<CeleryTask {}>'.format(self.id)
Exemple #4
0
class SolarEdgeUsagePoint(db.Model):
    __tablename__ = 'solar_edge_usage_points'
    id = db.Column(db.Integer, primary_key=True)
    energy_account_id = db.Column(db.Integer,
                                  db.ForeignKey('energy_accounts.id'))
    time_unit = db.Column(db.String(50))
    unit_of_measure = db.Column(db.String(50))
    date = db.Column(db.Date)
    value = db.Column(db.Numeric(20, 5))

    def __repr__(self):
        return '<SolarEdgeUsagePoint {}>'.format(self.id)
Exemple #5
0
class PGEUsagePoint(db.Model):
    __tablename__ = 'pge_usage_points'
    id = db.Column(db.Integer, primary_key=True)
    energy_account_id = db.Column(db.Integer,
                                  db.ForeignKey('energy_accounts.id'))
    commodity_type = db.Column(db.Integer)
    measuring_period = db.Column(db.Integer)
    interval_start = db.Column(db.DateTime)
    interval_duration = db.Column(db.Integer)
    interval_value = db.Column(db.Integer)
    flow_direction = db.Column(db.Integer)
    unit_of_measure = db.Column(db.Integer)
    power_of_ten_multiplier = db.Column(db.Integer)
    accumulation_behavior = db.Column(db.Integer)

    def __repr__(self):
        return '<PGEUsagePoint {}>'.format(self.id)
Exemple #6
0
from solarmonitor.utils import convert_to_kWh

from solarmonitor.extensions import bcrypt, db
import datetime
from datetime import timedelta
from dateutil.relativedelta import relativedelta
from flask.ext.login import AnonymousUserMixin
from sqlalchemy import func

today = datetime.datetime.today().date()
seven_days_ago = datetime.datetime.today().date() - timedelta(days=7)

energy_accounts = db.Table(
    'energy_accounts_users',
    db.Column('energy_account_id', db.Integer,
              db.ForeignKey('energy_accounts.id')),
    db.Column('user_id', db.Integer, db.ForeignKey('users.id')))

role_associations = db.Table(
    'users_roles', db.Column('role_id', db.Integer, db.ForeignKey('roles.id')),
    db.Column('user_id', db.Integer, db.ForeignKey('users.id')))

permission_associations = db.Table(
    'permissions_roles',
    db.Column('permission_id', db.Integer, db.ForeignKey('permissions.id')),
    db.Column('role_id', db.Integer, db.ForeignKey('roles.id')))


class Anonymous(AnonymousUserMixin):
    def __init__(self):
        self.full_name = 'Anonymous'