# Path: corr-db/corrdb/common/core.py
# def setup_app(name, config='config'):


from ..core import db
from bson import ObjectId
import datetime
import json

class StatModel(db.Document):
    """CoRR backend stat model.
    This model stores all the stats around  the platform usage.

    Attributes:
        created_at: A string value of the creation timestamp.
        interval: A string calue of the stat interval; yearly, monthly or daily
        ("2015_01-2015_12", "2015_08_1-2015_08_31", "2015_08_14_0_0_0-2015_08_14_23_59_59")
        possible_category: A list of stats categories.
        category: A string value for the concerned stat category with undefined as default.
        possible_periode: A list of all possible interval periodes.
        periode: A string value of the current interval periode with undefined as default.
        traffic: A long value of the traffic counter for the appropriate category.
            For user it is the number for the storage it is the size of the files, etc.
        extend: A dictionary of to add other fields to the stat model.
    """
    created_at = db.StringField(default=str(datetime.datetime.utcnow()))
    interval = db.StringField(required=True)
    possible_category = ["user", "project", "record", "storage", "message", "application", "comment", "undefined", "collaboration"]

# Path: corr-db/corrdb/common/core.py
# def setup_app(name, config='config'):


# Path: corr-db/corrdb/common/models/stat_model.py
from ..core import db
from bson import ObjectId
import datetime
import json


class StatModel(db.Document):
    """CoRR backend stat model.
    This model stores all the stats around  the platform usage.

    Attributes:
        created_at: A string value of the creation timestamp.
        interval: A string calue of the stat interval; yearly, monthly or daily
        ("2015_01-2015_12", "2015_08_1-2015_08_31", "2015_08_14_0_0_0-2015_08_14_23_59_59")
        possible_category: A list of stats categories.
        category: A string value for the concerned stat category with undefined as default.
        possible_periode: A list of all possible interval periodes.
        periode: A string value of the current interval periode with undefined as default.
        traffic: A long value of the traffic counter for the appropriate category.
            For user it is the number for the storage it is the size of the files, etc.
        extend: A dictionary of to add other fields to the stat model.
    """
    created_at = db.StringField(default=str(datetime.datetime.utcnow()))
    interval = db.StringField(required=True)
    possible_category = ["user", "project", "record", "storage", "message", "application", "comment", "undefined", "collaboration"]

    category = db.StringField(default="undefined", choices=possible_category)