<commit_before>from c2corg_api.scripts.migration.documents.waypoints.waypoint import \
    MigrateWaypoints


class MigrateParkings(MigrateWaypoints):

    def get_name(self):
        return 'parking'

    def get_count_query(self):
        return (
            'select count(*) from app_parkings_archives;'
        )

    def get_query(self):
        return (
            'select '
            '   id, document_archive_id, is_latest_version, elevation, '
            '   is_protected, redirects_to, '
            '   ST_Force2D(ST_SetSRID(geom, 3857)) geom,'
            '   public_transportation_rating, snow_clearance_rating, '
            '   lowest_elevation, public_transportation_types '
            'from app_parkings_archives '
            'order by id, document_archive_id;'
        )

    def get_count_query_locales(self):
        return (
            'select count(*) from app_parkings_i18n_archives;'
        )

    def get_query_locales(self):
        return (
            'select '
            '   id, document_i18n_archive_id, is_latest_version, culture, '
            '    name, description, public_transportation_description, '
            '    snow_clearance_comment, accommodation '
            'from app_parkings_i18n_archives '
            'order by id, document_i18n_archive_id;'
        )

    def get_document(self, document_in, version):
        return dict(
            document_id=document_in.id,
            version=version,
            waypoint_type='access',
            protected=document_in.is_protected,
            redirects_to=document_in.redirects_to,
            elevation=document_in.elevation,
            elevation_min=document_in.lowest_elevation,
            public_transportation_rating=self.convert_type(
                document_in.public_transportation_rating,
                MigrateParkings.public_transportation_ratings),
            snow_clearance_rating=self.convert_type(
                document_in.snow_clearance_rating,
                MigrateParkings.snow_clearance_ratings),
            public_transportation_types=self.convert_types(
                document_in.public_transportation_types,
                MigrateParkings.public_transportation_types)

        )

    def get_document_locale(self, document_in, version):
        description, summary = self.extract_summary(document_in.description)
        # TODO what about "accommodation"?
        return dict(
            document_id=document_in.id,
            id=document_in.document_i18n_archive_id,
            version=version,
            culture=document_in.culture,
            title=document_in.name,
            description=description,
            summary=summary,
            access=document_in.public_transportation_description,
            access_period=document_in.snow_clearance_comment
        )

    public_transportation_ratings = {
        '1': 'good',
        '2': 'poor',
        '3': 'no',
        '4': 'near',
        '5': 'seasonal'
    }

    snow_clearance_ratings = {
        '1': 'often',
        '2': 'sometimes',
        '3': 'naturally',
        '4': 'non_applicable'
    }

    public_transportation_types = {
        '0': 'bus',  # using bus for 0
        '1': 'train',
        '2': 'bus',<commit_msg>Don't default to 'bus'<commit_after>from c2corg_api.scripts.migration.documents.waypoints.waypoint import \
    MigrateWaypoints


class MigrateParkings(MigrateWaypoints):

    def get_name(self):
        return 'parking'

    def get_count_query(self):
        return (
            'select count(*) from app_parkings_archives;'
        )

    def get_query(self):
        return (
            'select '
            '   id, document_archive_id, is_latest_version, elevation, '
            '   is_protected, redirects_to, '
            '   ST_Force2D(ST_SetSRID(geom, 3857)) geom,'
            '   public_transportation_rating, snow_clearance_rating, '
            '   lowest_elevation, public_transportation_types '
            'from app_parkings_archives '
            'order by id, document_archive_id;'
        )

    def get_count_query_locales(self):
        return (
            'select count(*) from app_parkings_i18n_archives;'
        )

    def get_query_locales(self):
        return (
            'select '
            '   id, document_i18n_archive_id, is_latest_version, culture, '
            '    name, description, public_transportation_description, '
            '    snow_clearance_comment, accommodation '
            'from app_parkings_i18n_archives '
            'order by id, document_i18n_archive_id;'
        )

    def get_document(self, document_in, version):
        return dict(
            document_id=document_in.id,
            version=version,
            waypoint_type='access',
            protected=document_in.is_protected,
            redirects_to=document_in.redirects_to,
            elevation=document_in.elevation,
            elevation_min=document_in.lowest_elevation,
            public_transportation_rating=self.convert_type(
                document_in.public_transportation_rating,
                MigrateParkings.public_transportation_ratings),
            snow_clearance_rating=self.convert_type(
                document_in.snow_clearance_rating,
                MigrateParkings.snow_clearance_ratings),
            public_transportation_types=self.convert_types(
                document_in.public_transportation_types,
                MigrateParkings.public_transportation_types, [0])

        )

    def get_document_locale(self, document_in, version):
        description, summary = self.extract_summary(document_in.description)
        # TODO what about "accommodation"?
        return dict(
            document_id=document_in.id,
            id=document_in.document_i18n_archive_id,
            version=version,
            culture=document_in.culture,
            title=document_in.name,
            description=description,
            summary=summary,
            access=document_in.public_transportation_description,
            access_period=document_in.snow_clearance_comment
        )

    public_transportation_ratings = {
        '1': 'good',
        '2': 'poor',
        '3': 'no',
        '4': 'near',
        '5': 'seasonal'
    }

    snow_clearance_ratings = {
        '1': 'often',
        '2': 'sometimes',
        '3': 'naturally',
        '4': 'non_applicable'
    }

    public_transportation_types = {
        '1': 'train',
        '2': 'bus',
{'fraction_non_alphanumeric': 0.08458326890366476, 'fraction_numerical': 0.008813978660893769, 'mean_word_length': 2.1721432074546345, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4821394', 'n_tokens_mistral': 1964, 'n_tokens_neox': 1875, 'n_words': 279}