<commit_before>"""
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
"""
import logging

from rest_framework import serializers
from django.db import transaction
from gwells.models import ProvinceStateCode
from gwells.serializers import AuditModelSerializer
from registries.serializers import PersonBasicSerializer
from wells.models import (
    ActivitySubmission,
    Casing,
    CasingMaterialCode,
    CasingCode,
    DecommissionDescription,
    LinerPerforation,
    LithologyDescription,
    ProductionData,
    Screen,
    Well,
)


logger = logging.getLogger(__name__)


class ProductionDataSerializer(serializers.ModelSerializer):
    """Serializes production data"""
    class Meta:
        model = ProductionData
        fields = (
            'yield_estimation_method',
            'yield_estimation_rate',
            'yield_estimation_duration',
            'well_yield_unit',
            'static_level',
            'drawdown',
            'hydro_fracturing_performed',
            'hydro_fracturing_yield_increase',
            'recommended_pump_depth',
            'recommended_pump_rate',
        )


class CasingMaterialSerializer(serializers.ModelSerializer):
    class Meta:
        model = CasingMaterialCode
        fields = (
            'code',
            'description'
        )


class CasingCodeSerializer(serializers.ModelSerializer):
    class Meta:
        model = CasingCode
        fields = (
            'code',
            'description',
        )


class CasingSerializer(serializers.ModelSerializer):
    class Meta:
        model = Casing
        fields = (
            'start',
            'end',
            'diameter',
            'casing_code',
            'casing_material',
            'drive_shoe',
            'wall_thickness'
        )
        extra_kwargs = {
            'start': {'required': True},
            'end': {'required': True},
            'diameter': {'required': True}
        }


class DecommissionDescriptionSerializer(serializers.ModelSerializer):
    """Serializes Decommission Descriptions"""

    class Meta:
        model = DecommissionDescription
        fields = (
            'start',
            'end',
            'material',
            'observations'
        )
        extra_kwargs = {
            'start': {'required': True},
            'end': {'required': True},
        }


class ScreenSerializer(serializers.ModelSerializer):
    class Meta:
        model = Screen
        fields = (
            'start',
            'end',
            'internal_diameter',
            'assembly_type',
            'slot_size',
        )
        extra_kwargs = {
            'start': {'required': True},
            'end': {'required': True},
            'assembly_type': {'required': True}
        }


class LinerPerforationSerializer(serializers.ModelSerializer):
    class Meta:
        model = LinerPerforation
        fields = (
            # SUPER IMPORTANT: Don't include ID (liner_perforation_guid, well, or submission) as part of this
            # serializer, as it will break the stacking code. If you include the guid, then it will remain
            # stuck on a particular well/submission (unless I gues you pop it during serializing/
            # deserializing) when creating legacy submissions or re-creating well records etc.
            'start',
            'end',
        )


class LithologyDescriptionSerializer(serializers.ModelSerializer):
    """Serializes lithology description records"""
    class Meta:
        model = LithologyDescription
        fields = (
            'lithology_from',
            'lithology_to',
            'lithology_raw_data',
            'water_bearing_estimated_flow',
        )


class WellDetailSerializer(AuditModelSerializer):<commit_msg>add more fields to lithology serializer<commit_after>"""
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
"""
import logging

from rest_framework import serializers
from django.db import transaction
from gwells.models import ProvinceStateCode
from gwells.serializers import AuditModelSerializer
from registries.serializers import PersonBasicSerializer
from wells.models import (
    ActivitySubmission,
    Casing,
    CasingMaterialCode,
    CasingCode,
    DecommissionDescription,
    LinerPerforation,
    LithologyDescription,
    ProductionData,
    Screen,
    Well,
)


logger = logging.getLogger(__name__)


class ProductionDataSerializer(serializers.ModelSerializer):
    """Serializes production data"""
    class Meta:
        model = ProductionData
        fields = (
            'yield_estimation_method',
            'yield_estimation_rate',
            'yield_estimation_duration',
            'well_yield_unit',
            'static_level',
            'drawdown',
            'hydro_fracturing_performed',
            'hydro_fracturing_yield_increase',
            'recommended_pump_depth',
            'recommended_pump_rate',
        )


class CasingMaterialSerializer(serializers.ModelSerializer):
    class Meta:
        model = CasingMaterialCode
        fields = (
            'code',
            'description'
        )


class CasingCodeSerializer(serializers.ModelSerializer):
    class Meta:
        model = CasingCode
        fields = (
            'code',
            'description',
        )


class CasingSerializer(serializers.ModelSerializer):
    class Meta:
        model = Casing
        fields = (
            'start',
            'end',
            'diameter',
            'casing_code',
            'casing_material',
            'drive_shoe',
            'wall_thickness'
        )
        extra_kwargs = {
            'start': {'required': True},
            'end': {'required': True},
            'diameter': {'required': True}
        }


class DecommissionDescriptionSerializer(serializers.ModelSerializer):
    """Serializes Decommission Descriptions"""

    class Meta:
        model = DecommissionDescription
        fields = (
            'start',
            'end',
            'material',
            'observations'
        )
        extra_kwargs = {
            'start': {'required': True},
            'end': {'required': True},
        }


class ScreenSerializer(serializers.ModelSerializer):
    class Meta:
        model = Screen
        fields = (
            'start',
            'end',
            'internal_diameter',
            'assembly_type',
            'slot_size',
        )
        extra_kwargs = {
            'start': {'required': True},
            'end': {'required': True},
            'assembly_type': {'required': True}
        }


class LinerPerforationSerializer(serializers.ModelSerializer):
    class Meta:
        model = LinerPerforation
        fields = (
            # SUPER IMPORTANT: Don't include ID (liner_perforation_guid, well, or submission) as part of this
            # serializer, as it will break the stacking code. If you include the guid, then it will remain
            # stuck on a particular well/submission (unless I gues you pop it during serializing/
            # deserializing) when creating legacy submissions or re-creating well records etc.
            'start',
            'end',
        )


class LithologyDescriptionSerializer(serializers.ModelSerializer):
    """Serializes lithology description records"""
    class Meta:
        model = LithologyDescription
        fields = (
            'lithology_from',
            'lithology_to',
            'lithology_raw_data',
            'lithology_colour',
            'lithology_hardness',
            'lithology_moisture',
            'water_bearing_estimated_flow',
        )


class WellDetailSerializer(AuditModelSerializer):
{'fraction_non_alphanumeric': 0.08179510844485464, 'fraction_numerical': 0.0009229349330872173, 'mean_word_length': 2.174295129989015, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '1188026', 'n_tokens_mistral': 2246, 'n_tokens_neox': 2185, 'n_words': 607}