<commit_before>#!/usr/bin/env python3

# Akvo Reporting is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.

""" Import projects from Optimy for Aqua for All

Usage:

    python manage.py a4a_optimy_import [--project-id <optimy_project_id>]

"""

from itertools import groupby

from django.conf import settings
from django.core.management.base import BaseCommand
import requests

from akvo.rsr.iso3166 import ISO_3166_COUNTRIES
from akvo.rsr.models import (
    BudgetItem,
    BudgetItemLabel,
    Organisation,
    Partnership,
    Project,
    ProjectCustomField,
    ProjectLocation,
    RelatedProject,
)
from akvo.utils import custom_get_or_create_country

BASE_URL = "https://api.optimytool.com/v1.3"
USERNAME = settings.OPTIMY_USERNAME
PASSWORD = <PASSWORD>.<PASSWORD>
COUNTRY_NAME_TO_ISO_MAP = {name: code for code, name in ISO_3166_COUNTRIES}

PROGRAM_IDS = {
    "VIA Water": 9222,
    "SCALE": 9224,
}
FORM_QUESTION_MAPPING = {
    "68d4a00a-416d-5ce1-9c12-2d6d1dc1a047": {
        "title": "9900586f-3c4b-5e3e-a9e6-a209eb8cb8e3",
        # FIXME: subtitle?
        "cofinancing-budget": "6c05de7b-4031-5809-a692-a45beadf7cec",
        "a4a-budget": "b0268b0c-d7e9-513a-bb27-1de7c0ec593a",
        "total-budget": "322932f0-e294-5621-a37b-fd57fec9937a",
        "aqua-for-all-budget": "b0268b0c-d7e9-513a-bb27-1de7c0ec593a",
        "co-financing-budget": "6c05de7b-4031-5809-a692-a45beadf7cec",
        "start-date": "b785b97e-64f7-5149-a07b-7216497aa39f",
        "end-date": "d3c4132c-1e55-5177-943e-3afa25b092ab",
        "project-number": "683c31bc-d1d3-57f2-bf57-2e4c54894181",
        "country": "913bec17-7f11-540a-8cb5-c5803e32a98b",
        "summary": "02f1316c-4d5c-5989-8183-e392a634d23e",
        "program": "09c477bb-d887-5862-9b12-ea5ab566b363",
    }
}

<commit_msg>[#4391] Remove duplicate question mapping entries<commit_after>#!/usr/bin/env python3

# Akvo Reporting is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.

""" Import projects from Optimy for Aqua for All

Usage:

    python manage.py a4a_optimy_import [--project-id <optimy_project_id>]

"""

from itertools import groupby

from django.conf import settings
from django.core.management.base import BaseCommand
import requests

from akvo.rsr.iso3166 import ISO_3166_COUNTRIES
from akvo.rsr.models import (
    BudgetItem,
    BudgetItemLabel,
    Organisation,
    Partnership,
    Project,
    ProjectCustomField,
    ProjectLocation,
    RelatedProject,
)
from akvo.utils import custom_get_or_create_country

BASE_URL = "https://api.optimytool.com/v1.3"
USERNAME = settings.OPTIMY_USERNAME
PASSWORD = settings.OPTIMY_PASSWORD
COUNTRY_NAME_TO_ISO_MAP = {name: code for code, name in ISO_3166_COUNTRIES}

PROGRAM_IDS = {
    "VIA Water": 9222,
    "SCALE": 9224,
}
FORM_QUESTION_MAPPING = {
    "68d4a00a-416d-5ce1-9c12-2d6d1dc1a047": {
        "title": "9900586f-3c4b-5e3e-a9e6-a209eb8cb8e3",
        # FIXME: subtitle?
        "cofinancing-budget": "6c05de7b-4031-5809-a692-a45beadf7cec",
        "a4a-budget": "b0268b0c-d7e9-513a-bb27-1de7c0ec593a",
        "total-budget": "322932f0-e294-5621-a37b-fd57fec9937a",
        "start-date": "b785b97e-64f7-5149-a07b-7216497aa39f",
        "end-date": "d3c4132c-1e55-5177-943e-3afa25b092ab",
        "project-number": "683c31bc-d1d3-57f2-bf57-2e4c54894181",
        "country": "913bec17-7f11-540a-8cb5-c5803e32a98b",
        "summary": "02f1316c-4d5c-5989-8183-e392a634d23e",
        "program": "09c477bb-d887-5862-9b12-ea5ab566b363",
    }
}


{'fraction_non_alphanumeric': 0.11676569361921985, 'fraction_numerical': 0.14208214931542237, 'mean_word_length': 3.7392900856793148, 'pattern_counts': {'":': 28, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '408292', 'n_tokens_mistral': 1853, 'n_tokens_neox': 1597, 'n_words': 271}