multigp_toolkit.rsexporter
==========================

.. py:module:: multigp_toolkit.rsexporter

.. autoapi-nested-parse::

   Import Data from RaceSync



Attributes
----------

.. autoapisummary::

   multigp_toolkit.rsexporter.T
   multigp_toolkit.rsexporter.logger


Classes
-------

.. autoapisummary::

   multigp_toolkit.rsexporter.RaceSyncExporter


Module Contents
---------------

.. py:data:: T

.. py:data:: logger

.. py:class:: RaceSyncExporter(rhapi, multigp, verification)

   Actions for exporting data to RaceSync


   .. py:attribute:: _rhapi

      A stored instace of the RHAPI module



   .. py:attribute:: _multigp

      A stored instace of the MultiGPAPI module



   .. py:attribute:: _verification

      A stored instace of the SystemVerification module



   .. py:attribute:: _fpvscores

      An instance of FPVScoresAPI



   .. py:attribute:: active_sync

      Variable for checking if a results sync is active



   .. py:method:: get_mgp_pilot_id(pilot_id)

      Gets the MultiGP id for a pilot

      :param pilot_id: The database id for the pilot
      :return: The



   .. py:method:: generate_formated_race_data(race_info, selected_race, round_num, heat_num, event_url)

      Generates a slot and score package for each pilot for the provided race

      :param race_info: Data for the completed race
      :param event_url: The FPVScores event url
      :yield: Formated race data



   .. py:method:: slot_score(collection)

      Push generated data to MultiGP. Uses a gevent connection pool for parallel
      connections.

      :param data_generators: Generators for formating data.
      :return: Status of the push



   .. py:method:: _generate_fpvscores_conditions()

      Lazily generate the conditions for pushing to FPVScores

      :yield: Check statuses



   .. py:method:: _bundle_by_group(races)

      Group saved race meta by heat groups and then sorts
      each heat groups based on heat id.

      :param races: The saved race meta to organize
      :return: The sorted heat groups



   .. py:method:: _bundle_by_heat(races)

      Group saved race meta by heat id.

      :param races: A list of the saved race data
      :return: An organized group of race data



   .. py:method:: _parse_heat_group_data(selected_mgp_race, event_url, races)

      Parses class data in the `Generate Heat Groups` format
      to be compatible with MultiGP predefined heats.

      Round number is set to the internal group id + 1 and the heat number
      is set set to the index of the heat within the heat group

      **Race data may be lost if a pilot participates in more than one heat per round.
      This is due to a limitation with MultiGP limiting pilots to one heat per round.**

      :param selected_mgp_race: The selected MultiGP race
      :param event_url: The FPVScores event url
      :param races: The race data
      :yield: The formated data



   .. py:method:: _parse_heat_data(selected_mgp_race, event_url, races)

      Parses class data in the `Count Races per Heat` format
      to be compatible with MultiGP predefined heats.

      Uses the internal round number and the index of the heat
      within the raceclass.

      **Race data may be lost if a pilot participates in more than one heat per round.
      This is due to a limitation with MultiGP limiting pilots to one heat per round.**

      :param selected_mgp_race: The selected MultiGP race
      :param event_url: The FPVScores event url
      :param races: The race data
      :yield: The formated data



   .. py:method:: _parse_zippyq_data(selected_mgp_race, event_url, races)

      Parses class data to be compatible with ZippyQ.

      The zippyq round number is read from the heat metadata

      :param selected_mgp_race: The selected MultiGP race
      :param event_url: The FPVScores event url
      :param races: The race data
      :yield: The formated data



   .. py:method:: _parse_incremental_round_data(selected_mgp_race, event_url, races)

      Parses class data to be compatible with brackets or ladders.

      Each race increments the round number and
      the heat number is always set to 1.

      :param selected_mgp_race: The selected MultiGP race
      :param event_url: The FPVScores event url
      :param races: The race data
      :yield: The formated data



   .. py:method:: raceclass_slot_score(selected_mgp_race, selected_rh_class, event_url)

      Pushes race results for a selected RotorHazard class to a specific
      MultiGP race. Typically trigger by a manual button press in the
      user interface.

      :param selected_mgp_race: The MultiGP race to push to.
      :param selected_rh_class: The selected RotorHazard class id
      :param event_url: The FPVScores



   .. py:method:: _rankings_from_leaderboard_data(data)

      Generates formated pilot rankings from leaderboard data

      :param data: The input leaderboard data
      :return: Formated ranking data



   .. py:method:: push_bracketed_rankings(selected_mgp_race, selected_rh_class)

      Pushes the overall rankings of the selected RotorHazard race class
      to the MultiGP race.

      :param selected_mgp_race: The set MultiGP race
      :param selected_rh_class: The selected RotorHazard race class
      :return: Status



   .. py:method:: raceclass_rankings_push()

      Trigger a rankings push to all imported MultiGP races

      :return: Push status



   .. py:method:: raceclass_results_push(event_url = None)

      Trigger a results push to all imported MultiGP races



   .. py:method:: _gq_push_checks()

      System checks before pushing global qualifier data

      :return: The status of the checks



   .. py:method:: _run_fpvscores_sync(gq_active)

      Manage the data push to FPVScores

      :param gq_active: Configure the push for a global qualifier
      :return: The status and event url



   .. py:method:: zippyq_slot_score(args)

      Push results of a saved ZippyQ race to MultiGP

      :param args: Callback args



   .. py:method:: manual_push_results(args = None)

      Wrapper for _manual_push_results. Prevents multiple pushes from being active
      at once

      :param _args: Callback args, defaults to None



   .. py:method:: _manual_push_results(_args = None)

      Pushes the results of a RotorHazard class to MultiGP

      :param _args: Callback args, defaults to None



