<commit_before>from flask_restful import Resource, request
from flask import jsonify
from service.constants import DbConstants, ParamConstants, MatchConstants
from service.validator import Validator
from db.data import Accessor, AccessParams
from utils.converter import Converter, Types
import json

CFG_ASSIGN_VALIDATION = './cfg/validation/assignment.json' # ToDo: load on start up


class Backlog(Resource):
    def get(self):
        return jsonify(Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.SCRUM_SPRINT_BACKLOG,
             AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI,
             AccessParams.KEY_MATCH_PARAMS: {
                 AccessParams.OPERATOR_OR: [{ParamConstants.PARAM_TYPE: MatchConstants.TYPE_STORY},
                                        {ParamConstants.PARAM_TYPE: MatchConstants.TYPE_BUG}]}}))


class Sprint(Resource):
    def get(self):
        return jsonify(Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.SCRUM_SPRINT,
             AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE}))


class SprintTimeline(Resource):
    def get(self):
        found = Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.SCRUM_SPRINT_TIMELINE,
             AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE})
        return (
        [] if (not found or not ParamConstants.PARAM_TIMELINE in found) else jsonify(found[ParamConstants.PARAM_TIMELINE]))


class ComponentList(Resource):
    def get(self):
        found = Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.PROJECT_COMPONENTS,
             AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE})
        return (
        [] if (not found or not ParamConstants.PARAM_COMPONENT in found) else found[ParamConstants.PARAM_COMPONENT])


class GroupList(Resource):
    def get(self):
        return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.PROJECT_TEAM,
             AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI})


class EmployeeList(Resource):
    def get(self):
        return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.PROJECT_EMPLOYEES,
             AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI})


class Group(Resource):
    def delete(self, group):
        # ToDo: move dependencies cleanup to separated class
        accessor = Accessor.factory(DbConstants.CFG_DB_SCRUM_API)
        accessor.delete({AccessParams.KEY_COLLECTION: DbConstants.SCRUM_ASSIGNMENTS,
                         AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI,
                         AccessParams.KEY_MATCH_PARAMS: {
                             ParamConstants.PARAM_GROUP: group}})
        return accessor.delete({AccessParams.KEY_COLLECTION: DbConstants.PROJECT_TEAM,
                                AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE,
                                AccessParams.KEY_MATCH_PARAMS: {
                                    ParamConstants.PARAM_GROUP: group}}), 204

    def post(self):
        group = request.get_json()
        return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).upsert(
            {AccessParams.KEY_COLLECTION: DbConstants.PROJECT_TEAM,
             AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE,
             AccessParams.KEY_OBJECT: group,
             AccessParams.KEY_MATCH_PARAMS: {
                 ParamConstants.PARAM_GROUP: group[ParamConstants.PARAM_GROUP]}}), 201


class AssignmentList(Resource):
    def get(self):
        return jsonify(Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.SCRUM_ASSIGNMENTS,
             AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI}))
<commit_msg>triggers fixes - group deletion<commit_after>from flask_restful import Resource, request
from flask import jsonify
from service.constants import DbConstants, ParamConstants, MatchConstants
from service.validator import Validator
from db.data import Accessor, AccessParams
from utils.converter import Converter, Types
import json

CFG_ASSIGN_VALIDATION = './cfg/validation/assignment.json' # ToDo: load on start up


class Backlog(Resource):
    def get(self):
        return jsonify(Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.SCRUM_SPRINT_BACKLOG,
             AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI,
             AccessParams.KEY_MATCH_PARAMS: {
                 AccessParams.OPERATOR_OR: [{ParamConstants.PARAM_TYPE: MatchConstants.TYPE_STORY},
                                        {ParamConstants.PARAM_TYPE: MatchConstants.TYPE_BUG}]}}))


class Sprint(Resource):
    def get(self):
        return jsonify(Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.SCRUM_SPRINT,
             AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE}))


class SprintTimeline(Resource):
    def get(self):
        found = Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.SCRUM_SPRINT_TIMELINE,
             AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE})
        return (
        [] if (not found or not ParamConstants.PARAM_TIMELINE in found) else jsonify(found[ParamConstants.PARAM_TIMELINE]))


class ComponentList(Resource):
    def get(self):
        found = Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.PROJECT_COMPONENTS,
             AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE})
        return (
        [] if (not found or not ParamConstants.PARAM_COMPONENT in found) else found[ParamConstants.PARAM_COMPONENT])


class GroupList(Resource):
    def get(self):
        return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.PROJECT_TEAM,
             AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI})


class EmployeeList(Resource):
    def get(self):
        return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.PROJECT_EMPLOYEES,
             AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI})


class Group(Resource):
    def delete(self, group):
        return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).delete(
            {AccessParams.KEY_COLLECTION: DbConstants.PROJECT_TEAM, AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE,
             AccessParams.KEY_MATCH_PARAMS: {ParamConstants.PARAM_GROUP: group}}), 204

    def post(self):
        group = request.get_json()
        return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).upsert(
            {AccessParams.KEY_COLLECTION: DbConstants.PROJECT_TEAM,
             AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE,
             AccessParams.KEY_OBJECT: group,
             AccessParams.KEY_MATCH_PARAMS: {
                 ParamConstants.PARAM_GROUP: group[ParamConstants.PARAM_GROUP]}}), 201


class AssignmentList(Resource):
    def get(self):
        return jsonify(Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get(
            {AccessParams.KEY_COLLECTION: DbConstants.SCRUM_ASSIGNMENTS,
             AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI}))

{'fraction_non_alphanumeric': 0.08258988915923222, 'fraction_numerical': 0.0016220600162206002, 'mean_word_length': 3.223173515981735, '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': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4300043', 'n_tokens_mistral': 2191, 'n_tokens_neox': 2130, 'n_words': 352}