def get_latest_package(artifact, package_name):
  if package_name:
    package_list = Package.objects.filter(
      artifact=artifact, name=package_name,
    ).order_by('id').reverse()
  else:
    package_list = Package.objects.filter(
      artifact=artifact,
    ).order_by('id').reverse()

  if len(package_list) > 0:
    return package_list[0]
  else:
    return None
dataset/ETHPy150Open XiaoMi/minos/tank/package_server/views.py/get_latest_package/original