src/graphQL/Queries.js

mail@pastecode.io avatar
unknown
typescript
25 days ago
9.9 kB
1
Indexable
Never
import { gql } from '@apollo/client'

export const GET_COMPANY_INFOS = gql`
  query {
    companyInfos {
      display_name
      id
    }
  }
`

export const GET_USER_AUTH = email => gql`
  query {
    user_authorization(email: "${email}") {
      railroad_id
      company_id
      user_id
      display_name
      role_names
    }
  }
`

export const GET_DAY_RESULTS = (companyId, startDate, endDate) => gql`
  query {
    dayResults(
      company_id: ${companyId},
      Start_date:"${startDate}",
      End_date: "${endDate}"
    ){
      compliance
      fuel_saving
      fuel_saved
      report_date
    }
  }
`

export const GET_FUEL_MILE_RESULTS = (companyId, startDate, endDate) => gql`
  query {
    fuelMileResults(
      company_id: ${companyId}
      Start_date: "${startDate}"
      End_date: "${endDate}"
    ){
      date
      total_fuel
      total_miles
    }
  }
`

export const GET_LOCO_INFRACTIONS = (
  companyId,
  locoNum,
  startDate,
  endDate
) => gql`
  query {
    locoInfractions(
      company_id: ${companyId}
       ${locoNum ? 'LocoNum:' + locoNum : ''}
      Start_date: "${startDate}"
      End_date: "${endDate}"
    ) {
      Duration
      StartSpeed
      LocoNum
      Start_event
      InfraDate
      StartTime
    }
  }
`

export const GET_TRIP_FUEL_SAVING = (
  companyId,
  locoNum,
  startDate,
  endDate
) => gql`
  query {
    tripFuelSaving(
      company_id: ${companyId}
       ${locoNum ? 'LocoNum:' + locoNum : ''}
      Start_date: "${startDate}"
      End_date: "${endDate}"
    ) {
      Date
      Time
      LocoNum
      FromStation
      ToStation
      DistanceTravelled
      FuelConsumed
      PercentSavings
      Compliance
    }
  }
`

export const GET_TRIPS = gql`
  query Trips(
    $railroad_id: String!
    $start_date_utc: DateTime!
    $end_date_utc: DateTime!
  ) {
    trips(
      railroad_id: $railroad_id
      start_date_utc: $start_date_utc
      end_date_utc: $end_date_utc
    ) {
      end_date_utc
      crew_id
      email
      end_location
      loco_id
      simple_train_consist_id
      start_date_utc
      start_location
      train_id
      trip_complete
      trip_duration_secs
      trip_id
      user_id
      blocks_trip
      data_availability
    }
  }
`

export const GET_TRIPS_DETAILS = gql`
  query TripDetails($trip_id: String!) {
    trip_details(trip_id: $trip_id) {
      summary {
        total_recommendation_count
        overall_compliance
        savings_achieved_l
        expected_savings_l
      }
      movements {
        movement_id
        start_location_abbreviation
        end_location_abbreviation
        movement_distance_mi
        fuel_consumed_l
        fuel_saved_l
        avg_compliance_percent_time
        avg_fuel_efficiency
        data_anomaly
        compliances {
          recommendation_id
          recommendation_type
          start_time_utc
          end_time_utc
          start_milepost
          end_milepost
          possible_compliance_distance_mi
          actual_compliance_distance_mi
          movement_id
        }
        end_time_utc
        start_time_utc
      }
    }
  }
`

export const GET_LOCOMOTIVES = gql`
  query Locomotives($railroad_id: String!) {
    locomotives(railroad_id: $railroad_id) {
      locomotive_id
    }
  }
`

export const GET_FUEL_SAVING_HERO_METRICS = gql`
  query FuelSavingHeroMetrics(
    $railroad_id: String!
    $start_date_utc: DateTime!
    $end_date_utc: DateTime!
    $route_id: String
    $route_direction: String
  ) {
    fuel_saving_hero_metrics(
      railroad_id: $railroad_id
      start_date_utc: $start_date_utc
      end_date_utc: $end_date_utc
      route_id: $route_id
      route_direction: $route_direction
    ) {
      total_distance_miles
      fuel_saved_litres
      fuel_saved_kg_of_c02
      fuel_efficiency_ltkm
    }
  }
`

export const GET_FUEL_SAVING_TRENDS = gql`
  query FuelSavingTrends(
    $railroad_id: String!
    $start_date_utc: DateTime!
    $end_date_utc: DateTime!
    $route_id: String
    $route_direction: String
  ) {
    fuel_saving_trends(
      railroad_id: $railroad_id
      start_date_utc: $start_date_utc
      end_date_utc: $end_date_utc
      route_id: $route_id
      route_direction: $route_direction
    ) {
      fuel_saving_trends {
        daily_fuel_saving_percent
        daily_compliance_percent
        daily_distance_travelled_miles
        daily_fuel_consumed_litres
        daily_estimated_fuel_consumed_litres
        day
        daily_fuel_efficiency_ltkm
        daily_baseline_fuel_efficiency_ltkm
        daily_gross_ton_km
      }
    }
  }
`

export const GET_ROUTES_BY_RAILROAD = gql`
  query RoutesByRailroad($railroad_id: String!) {
    routes_by_railroad_id(railroad_id: $railroad_id) {
      route_id
      route_name
      sub_division
      railroad_id
      corridor
    }
  }
`

export const GET_TRIP = gql`
  query GetTrip($trip_id: String!) {
    get_trip(trip_id: $trip_id) {
      artifact_uri
      blocks_trip
      car_count
      crew_id
      data_availability_bitmask
      ecorail_tier
      end_location
      end_date_utc
      extra_locomotive_info
      is_test
      loco_id
      locomotive_count
      railroad_id
      route_direction
      route_id
      simple_train_consist_id
      start_date_utc
      start_location
      total_length_m
      total_weight_kg
      train_id
      trip_complete
      trip_duration_secs
      trip_id
      user_id
      email
      data_availability
    }
  }
`

export const GET_TRIP_BY_STC_ID = gql`
  query GetTrip($simple_train_consist_id: String!) {
    get_trip(simple_train_consist_id: $simple_train_consist_id) {
      artifact_uri
      blocks_trip
      car_count
      crew_id
      data_availability_bitmask
      ecorail_tier
      end_location
      extra_locomotive_info
      end_date_utc
      is_test
      loco_id
      locomotive_count
      railroad_id
      route_direction
      route_id
      simple_train_consist_id
      start_date_utc
      start_location
      total_length_m
      total_weight_kg
      train_id
      trip_complete
      trip_duration_secs
      trip_id
      user_id
      email
      data_availability
    }
  }
`

export const GET_USERS_AND_ROLES_BY_EMAIL = gql`
  query UsersAndRolesByEmail($email: String!) {
    users_and_roles_by_email(email: $email) {
      created_at_utc
      email
      is_test
      railroad_id
      role_bitmask
      roles
      updated_at_utc
      user_id
    }
  }
`

export const GET_STATIONS_BY_ROUTE_ID = gql`
  query StationsByRouteId($railroadId: String!, $routeId: String!) {
    stations_by_route_id(railroad_id: $railroadId, route_id: $routeId) {
      lng
      lat
      location_name
      abbreviation
      route_id
      sequence_id
    }
  }
`

export const GET_FEATURIZERS_TRIP_INFORMATION_ON_PATH = gql`
  query FeaturizersTripInformationOnPath(
    $expirySecs: Int!
    $simpleTrainConsistId: String!
  ) {
    get_featurizers_trip_information_path(
      expiry_secs: $expirySecs
      simple_train_consist_id: $simpleTrainConsistId
    ) {
      presigned_url
    }
  }
`

export const GET_BROADCAST_DATA_BY_RAILROAD_ID = gql`
  query BroadcastDataByRailroadId($railroadId: String!) {
    get_broadcast_data_by_railroad_id(railroad_id: $railroadId) {
      loco_gps_data_points {
        alt_m
        course
        lat
        lng
        speed_mps
        stc_id
        timestamp_utc
        gps_source
      }
      loco_id
      railroad_id
    }
  }
`

export const GET_LOCALIZATION_UNITS = gql`
  query GetLocalizationUnits($railroad_id: String!) {
    localization_units(railroad_id: $railroad_id) {
      date_format
      date_time_format
      distance_unit
      fuel_unit
      railroad_id
      small_distance_unit
      speed_unit
      time_format
      weight_unit
      fuel_efficiency_unit
      volume_unit
    }
  }
`

export const GET_FEATURIZERS_INTERPOLATE_REVERIFY_PATH = gql`
  query FeaturizersInterpolateReverifyPath(
    $expirySecs: Int!
    $simpleTrainConsistId: String!
  ) {
    get_featurizers_interpolate_reverify_path(
      expiry_secs: $expirySecs
      simple_train_consist_id: $simpleTrainConsistId
    ) {
      presigned_url
    }
  }
`

export const GET_ZONE_SPEED_LIMITS_BY_ROUTES_ID = gql`
  query GetZoneSpeedLimitsByRoutesId(
    $railroadId: String!
    $routeId: String!
    $startDestinationId: String!
    $endDestinationId: String!
  ) {
    track_data(
      railroad_id: $railroadId
      route_id: $routeId
      start_destination_id: $startDestinationId
      end_destination_id: $endDestinationId
    ) {
      speed_limits {
        end_distance_miles
        end_mile
        speed_limit_mph
        start_distance_miles
        start_mile
        subdivision
      }
    }
  }
`

export const GET_TSO_SPEED_LIMITS_BY_ROUTES_ID = gql`
  query GetTSOSpeedLimitsByRoutesId(
    $railroadId: String!
    $routeId: String!
    $startDestinationId: String!
    $endDestinationId: String!
  ) {
    track_data(
      railroad_id: $railroadId
      route_id: $routeId
      start_destination_id: $startDestinationId
      end_destination_id: $endDestinationId
    ) {
      temporary_speed_limits {
        absolute_track_distance_miles
        created_at_utc
        direction
        geom
        is_expired
        milepost
        route_id
        speed_limit_mph
        speed_limit_type
        subdivision
        temporary_speed_limit_id
        updated_at_utc
      }
    }
  }
`
Leave a Comment