<commit_before># -*- coding: utf-8 -*-

from sqlalchemy import or_, asc, desc, and_, distinct
from sqlalchemy import func, Integer, String, Text, Date, Float
from sqlalchemy.ext.hybrid import hybrid_property, hybrid_method
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
from sqlalchemy.orm import aliased, relationship

from ..helpers import image_url, project_url, project_widget_url
from ..helpers import utc_from_local, get_lang
from ..cacher import cacher
from ..base_resources import AbstractLang
from ..models.post import Post, Blog
from .. import db


class ProjectLang(AbstractLang, db.Model):
    __tablename__ = 'project_lang'

    id = db.Column('id', String(50),
                   db.ForeignKey('project.id'), primary_key=True)
    lang = db.Column('lang', String(2), primary_key=True)
    # name = db.Column('name', String(100))
    subtitle = db.Column('subtitle', Text)
    description = db.Column('description', Text)
    motivation = db.Column('motivation', Text)
    about = db.Column('about', Text)
    related = db.Column('related', Text)
    reward = db.Column('reward', Text)
    keywords = db.Column('keywords', Text)
    video = db.Column('video', String(255))
    media = db.Column('media', String(255))
    pending = db.Column('pending', Integer)
    Project = relationship('Project', back_populates='Translations')

    def __repr__(self):
        return '<ProjectLang %s(%s): %r>' % (
            self.id, self.lang, self.subtitle)

    @hybrid_property
    def description_short(self):
        return self.subtitle


class Project(db.Model):
    """
        Projects status
        ===============
        status = 0 : Non considered or rejected
        status = 1 : EDITING, considerations:
                     - DRAFT if it has an "ugly" id
                     - NEGOTIATION:
                        if it has a "nice" id:
                            (prior status was 2).
                            Meaning, "needs more work by the user"
                        if it has the "updated":
                            date set means "still needs more work"
                     with date updated set
        status = 2 : REVIEWING (has a "nice" id), considerations:
                     - REVIEW PENDING if it doesn't have the "updated" date set
                     - SECOND REVIEW PENDING if it has the "updated" date set
                        (when it's coming from a second edition by the user)
        status = 3 : Published (hast the "updated" date set)
                               during the 2 rounds
                     Funded if the has passed the first round
        status = 4 : Funded, after the 2 rounds only
        status = 5 : Fulfilled, after funded an editor can decide
                     to put this status meaning "Outstanding project"
        status = 6 : Project failed after an unsuccessful campaign

        """
    __tablename__ = 'project'

    # PROJECT STATUS IDs
    STATUS_REJECTED = 0
    STATUS_EDITING = 1  # editing
    STATUS_REVIEWING = 2  # reviewing
    STATUS_IN_CAMPAIGN = 3
    STATUS_FUNDED = 4
    STATUS_FULFILLED = 5  # 'Caso de exito'
    STATUS_UNFUNDED = 6  # proyecto fallido
    STATUS_STR = ('rejected',
                  'editing',
                  'reviewing',
                  'in_campaign',
                  'funded',
                  'fulfilled',
                  'unfunded')

    RECEIVED_PROJECTS = [STATUS_REVIEWING,
                         STATUS_IN_CAMPAIGN,
                         STATUS_FUNDED,
                         STATUS_FULFILLED,
                         STATUS_UNFUNDED]
    PUBLISHED_PROJECTS = [STATUS_IN_CAMPAIGN,
                          STATUS_FUNDED,
                          STATUS_FULFILLED,
                          STATUS_UNFUNDED]
    SUCCESSFUL_PROJECTS = [STATUS_IN_CAMPAIGN,
                           STATUS_FUNDED,
                           STATUS_FULFILLED]

    SCOPES_STR = ('', 'local', 'regional', 'national', 'global')
<commit_msg>fix received projects<commit_after># -*- coding: utf-8 -*-

from sqlalchemy import or_, asc, desc, and_, distinct
from sqlalchemy import func, Integer, String, Text, Date, Float
from sqlalchemy.ext.hybrid import hybrid_property, hybrid_method
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
from sqlalchemy.orm import aliased, relationship

from ..helpers import image_url, project_url, project_widget_url
from ..helpers import utc_from_local, get_lang
from ..cacher import cacher
from ..base_resources import AbstractLang
from ..models.post import Post, Blog
from .. import db


class ProjectLang(AbstractLang, db.Model):
    __tablename__ = 'project_lang'

    id = db.Column('id', String(50),
                   db.ForeignKey('project.id'), primary_key=True)
    lang = db.Column('lang', String(2), primary_key=True)
    # name = db.Column('name', String(100))
    subtitle = db.Column('subtitle', Text)
    description = db.Column('description', Text)
    motivation = db.Column('motivation', Text)
    about = db.Column('about', Text)
    related = db.Column('related', Text)
    reward = db.Column('reward', Text)
    keywords = db.Column('keywords', Text)
    video = db.Column('video', String(255))
    media = db.Column('media', String(255))
    pending = db.Column('pending', Integer)
    Project = relationship('Project', back_populates='Translations')

    def __repr__(self):
        return '<ProjectLang %s(%s): %r>' % (
            self.id, self.lang, self.subtitle)

    @hybrid_property
    def description_short(self):
        return self.subtitle


class Project(db.Model):
    """
        Projects status
        ===============
        status = 0 : Non considered or rejected
        status = 1 : EDITING, considerations:
                     - DRAFT if it has an "ugly" id
                     - NEGOTIATION:
                        if it has a "nice" id:
                            (prior status was 2).
                            Meaning, "needs more work by the user"
                        if it has the "updated":
                            date set means "still needs more work"
                     with date updated set
        status = 2 : REVIEWING (has a "nice" id), considerations:
                     - REVIEW PENDING if it doesn't have the "updated" date set
                     - SECOND REVIEW PENDING if it has the "updated" date set
                        (when it's coming from a second edition by the user)
        status = 3 : Published (hast the "updated" date set)
                               during the 2 rounds
                     Funded if the has passed the first round
        status = 4 : Funded, after the 2 rounds only
        status = 5 : Fulfilled, after funded an editor can decide
                     to put this status meaning "Outstanding project"
        status = 6 : Project failed after an unsuccessful campaign

        """
    __tablename__ = 'project'

    # PROJECT STATUS IDs
    STATUS_REJECTED = 0
    STATUS_EDITING = 1  # editing
    STATUS_REVIEWING = 2  # reviewing
    STATUS_IN_CAMPAIGN = 3
    STATUS_FUNDED = 4
    STATUS_FULFILLED = 5  # 'Caso de exito'
    STATUS_UNFUNDED = 6  # proyecto fallido
    STATUS_STR = ('rejected',
                  'editing',
                  'reviewing',
                  'in_campaign',
                  'funded',
                  'fulfilled',
                  'unfunded')

    RECEIVED_PROJECTS = [STATUS_REJECTED,
                         STATUS_EDITING,
                         STATUS_REVIEWING,
                         STATUS_IN_CAMPAIGN,
                         STATUS_FUNDED,
                         STATUS_FULFILLED,
                         STATUS_UNFUNDED]
    PUBLISHED_PROJECTS = [STATUS_IN_CAMPAIGN,
                          STATUS_FUNDED,
                          STATUS_FULFILLED,
                          STATUS_UNFUNDED]
    SUCCESSFUL_PROJECTS = [STATUS_IN_CAMPAIGN,
                           STATUS_FUNDED,
                           STATUS_FULFILLED]

    SCOPES_STR = ('', 'local', 'regional', 'national', 'global')

{'fraction_non_alphanumeric': 0.0895264003956968, 'fraction_numerical': 0.0074193149499196245, 'mean_word_length': 1.863008849557522, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '1654141', 'n_tokens_mistral': 2354, 'n_tokens_neox': 2177, 'n_words': 654}