def edit_observation(pattern_type, id):
    """
    This API is used to edit the observation based on the available record.
    :param pattern_type:
    :param id:
    """
    fs = accessing_data_via_id(build_id=f"{id}")
    if fs.count() == 0:
        return render_template("404.html", title="404"), 404
    record = Common.collection_creation(fs)[0]
    form = ObservationUpdate(request.form)
    if request.method == "POST":
        Common.logger.info(
            f"edit_observation: Post API called against id {id} and pattern type"
            f" {pattern_type}")
        observations = ast.literal_eval(form.data["observation_data"])
        try:
            Common.logger.info(
                f"edit_observation: The provided observation is {observations}"
                f" {pattern_type}")
            if pattern_type not in Common.get_config_value("test_map"):
                if type(observations) is dict:
                    for observation in observations:
                        db_update(
                            observation_record_key=f"{observation}",
                            observation_record_value="{}".format(
                                observations[observation]),
                        )
                record["Validation"] = Common.record_updater(
                    record["Validation"], observations)
                update_record(f"{id}", old_record=record)
            else:
                os.popen("touch problem_in_before_update")
                failed_test_details = {
                    "test_details":
                    record["Validation"]["Pre_Upgrade_test_Failure"]
                }
                updated_data = Common.record_updater(failed_test_details,
                                                     observations)
                record["Validation"][
                    "Pre_Upgrade_test_Failure"] = updated_data["test_details"]
                update_record(f"{id}", old_record=record)
        except Exception as ex:
            Common.logger.warn(
                f"edit_observation: The provided dictionary is not in correct "
                f"format {ex}")
            flash(
                "Please provide the proper dictionary format {} of pattern {}".
                format(observations, pattern_type))
            return render_template("observation.html",
                                   form=form,
                                   pattern_type=pattern_type,
                                   record=record)
        flash("Data Submitted Successfully")
    return render_template("observation.html",
                           form=form,
                           pattern_type=pattern_type,
                           record=record)
    def log_analysis(self, build_number, validation_data):
        """
        This method is used to analyse the logs based on users request, and upload their
        results in mongodb database as well as xls file in report folder.
        :param int build_number:
        :param dict validation_data:
        """
        self.header_of_table()
        job_file_name = self.prop_obj.job_mapper[build_number][
            "build_file_name"]
        Common.logger.info(f"[log_analysis]: headers of xls table updated")
        build_status = LogAnalyser.ran_job_status(job_file_name)
        machine_address = LogAnalyser.machine_details(job_file_name)

        upgrade_validation_result = Validation.job_analysis(
            validation_data,
            job_file_name,
            machine_address,
            self.prop_obj.job_mapper[build_number]["skip_check"],
        )
        Common.logger.info(f"[log_analysis]: Updated validation checked")

        job_time_stamp = time.ctime(
            self.prop_obj.job_mapper[build_number]["time_stamp"])
        xls_report_content = [
            validation_data["job_name"],
            build_number,
            build_status,
            upgrade_validation_result,
            self.prop_obj.job_mapper[build_number]["time_stamp"],
        ]

        analysis_result = {
            "Job-Name":
            validation_data["job_name"],
            "Build-Number":
            build_number,
            "Build-Status":
            build_status,
            "Validation":
            upgrade_validation_result,
            "Job-Time-Stamp":
            job_time_stamp,
            "Build-Version":
            self.prop_obj.job_mapper[build_number]["build_version"],
            "Snap-Version":
            self.prop_obj.job_mapper[build_number]["snap_no"],
            "SystemLog":
            upgrade_validation_result["System_Log"]
            if "System_Log" in upgrade_validation_result else None,
            "Job Url":
            self.prop_obj.job_mapper[build_number]["build_url"],
        }
        Common.logger.info("[log_analysis] Analysis result collected")
        observated_data_object = accessing_observation_db()
        if observated_data_object.count() >= 1:
            observated_data = Common.collection_creation(
                observated_data_object)
            try:
                for observated_content in observated_data:
                    observated_content.pop("_id")
                    analysis_result["Validation"] = Common.record_updater(
                        analysis_result["Validation"], observated_content)
            except Exception as ex:
                Common.logger.warn(
                    f"[log_analysis]: Exception observed while comparing the"
                    f" observation while evaluating the job: {ex}")

        db_update(analysis_result)
        DataUpdater.test_result_update(
            self.prop_obj.sheets_number[self.prop_obj.sheets],
            self.prop_obj.rows_no,
            xls_report_content,
        )
        Common.logger.info(
            f"[log_analysis] Analysis completed for build {build_number}")