Skip to content

Fix "similar-code" issue in project/main/data/drone_flight_log.py #91

Description

@SabCampos

Similar blocks of code found in 2 locations. Consider refactoring.

https://codeclimate.com/github/qAIRa/qAIRaMapAPI-OpenSource/project/main/data/drone_flight_log.py#issue_6145041de37de2000100008a

Both endpoints query a different table but with the parameters that are comparably similar to each other. We would like to know if this issue can be fixed.

Endpoint 1:

  @app.route('/api/flight_log_info_during_flight/', methods=['GET'])
  def getFlightLogDuringFlight():
      """ Lists all measurements of processed measurement of the target qHAWAX within the initial and final date """
      try:
          allQhawaxsInFlight = get_data_helper.AllqHAWAXIsInFlight()
          if(allQhawaxsInFlight!=[]):
              return make_response(jsonify(allQhawaxsInFlight), 200)
          return make_response(jsonify('There are no qHAWAXs in flight'), 200)
      except TypeError as e:
          json_message = jsonify({'error': '\'%s\'' % (e)})
          return make_response(json_message, 400)

Endpoint 2:

  @app.route('/api/mobile_log_info_during_trip/', methods=['GET'])
  def getMobileLogDuringTrip():
      try:
          allQhawaxsInFlight = get_data_helper.AllqHAWAXIsInTrip()
          if(allQhawaxsInFlight!=[]):
              return make_response(jsonify(allQhawaxsInFlight), 200)
          return make_response(jsonify('There are no qHAWAXs in a trip'), 200)
      except TypeError as e:
          json_message = jsonify({'error': '\'%s\'' % (e)})
          return make_response(json_message, 400)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions