class SegmentIntervalMetrics(ObjectType): fromStopId = String() toStopId = String() medianTripTime = Float() scheduledMedianTripTime = Float() trips = Int() scheduledTrips = Int() # parent is a metrics.SegmentIntervalMetrics object def resolve_fromStopId(segment_metrics, info): return segment_metrics.from_stop_id def resolve_toStopId(segment_metrics, info): return segment_metrics.to_stop_id def resolve_medianTripTime(segment_metrics, info): return segment_metrics.get_median_trip_time(scheduled=False) def resolve_scheduledMedianTripTime(segment_metrics, info): return segment_metrics.get_median_trip_time(scheduled=True) def resolve_trips(segment_metrics, info): return segment_metrics.get_num_trips(scheduled=False) def resolve_scheduledTrips(segment_metrics, info): return segment_metrics.get_num_trips(scheduled=True)
class Cloud(ObjectType): name = String() geo_region = String() geo_longitude = Float() geo_latitude = Float() cloud_description = String() cloud_provider = String() @staticmethod def resolve_name(parent, info): return parent["cloud_name"] @staticmethod def resolve_geo_region(parent, info): return parent["geo_region"] @staticmethod def resolve_longitude(parent, info): return parent["geo_longitude"] @staticmethod def resolve_geo_latitude(parent, info): return parent["geo_latitude"] @staticmethod def resolve_cloud_descrpition(parent, info): return parent["cloud_description"] @staticmethod def resolve_cloud_provider(parent, info): cloud_name = parent["cloud_name"] return cloud_name.split("-")[0]
class PlaceType(ObjectType): id = ID(required=True) created_at = DateTime(required=True) updated_at = DateTime(required=True) address = String(required=True) longitude = Float(required=True) latitude = Float(required=True) gallery = List(FileType) work_time = String(required=True) preorder = Boolean(required=True) restaurant = Field(RestaurantType, required=True) tables = List('app.schema.types.TableType') async def resolve_restaurant(parent: PlaceModel, info: ResolveInfo) -> RestaurantModel: restaurant = await RestaurantResolver.resolve_place_restaurant( parent, info) return restaurant async def resolve_tables(parent: PlaceModel, info: ResolveInfo) -> typing.List[TableModel]: tables = await RestaurantResolver.resolve_place_tables(parent, info) return tables async def resolve_gallery(parent: PlaceModel, info: ResolveInfo) -> typing.List[FileModel]: gallery = await RestaurantResolver.resolve_place_gallery(parent, info) return gallery
class RecipeNode(PrimaryKeyMixin, DjangoObjectType): image_url = String(resolver=resolvers.resolve_image_url) is_published = Boolean(resolver=resolvers.resolve_is_published) total_comments = Int(resolver=resolvers.resolve_total_comments) total_down_votes = Int(resolver=resolvers.resolve_total_down_votes) total_ingredients = Int(resolver=resolvers.resolve_total_ingredients) total_steps = Float(resolver=resolvers.resolve_total_steps) total_up_votes = Int(resolver=resolvers.resolve_total_up_votes) total_time = Float(resolver=resolvers.resolve_total_time) class Meta: model = models.Recipe interfaces = (Node, ) @classmethod def get_node(cls, info, pk): return models.Recipe.objects \ .select_related('author') \ .prefetch_related('ingredients') \ .prefetch_related('steps') \ .get(pk=pk) def resolve_steps(self, info): return models.Step.objects \ .filter(Q(recipe_step_relationships__recipe__pk=self.pk)) \ .order_by('recipe_step_relationships__order') \ .all()
class ProposalAllocatedTime(ObjectType): partner = Field(Partner) p0 = Float() p1 = Float() p2 = Float() p3 = Float() p4 = Float()
class StatisticsTarget(ObjectType): """ The statistics related to SALT targets """ is_optional = Boolean() right_ascension = Float() declination = Float()
class Trail(ObjectType): id = Int(required=True) name = String(required=True) surface = Surface state = State latitude = Float(required=True) longitude = Float(required=True) def resolve_surface(trail, info): db_cursor.execute( """ SELECT surface.id, firstName, FROM surface INNER JOIN trail ON trail.surfaceID = surface.id WHERE surface.id = %(trail_pk)s """, {"trail_pk": trail['trail_id']}) return [Surface(**row_data) for row_data in db_cursor.fetchall()] def resolve_state(trail, info): db_cursor.execute( """ SELECT state.abbrev, name FROM state INNER JOIN trail ON trail.stateAbbrev = state.abbrev WHERE state.abbrev = %(trail_pk)s """, {"trail_pk": trail['trail_id']}) return [State(**row_data) for row_data in db_cursor.fetchall()]
class Event(ObjectType): scenarioId = ID(required=True, description="Scenario identifier") type = String(required=True) path = List(String, required=True) timestamp = Float(required=True, description="Timestampt of event") locator = String(required=True) url = String(required=True) content = String(required=False) screenX = Int(required=True) screenY = Int(required=True) pageTime = Float(required=True) # Ziskanie zoznamu udalosti vramci scenara def getTest(self, aggClient, argv): response = aggClient.sendCommand('getTest', argv) answer = [] if response['status']: for item in response['data']: tmpObj = Event(item['scenarioId'], item['type'], item['path'], item['timestamp'], item['locator'], item['url'], item['screenX'], item['screenY'], item['pageTime']) if 'content' in item: tmpObj.content = item['content'] answer.append(tmpObj) else: raise GraphQLError(response['error']) return answer
class Input: name = String(required=False) num_guests = Int(required=False) bed_rooms = Int(required=False) beds = Int(required=False) bath_rooms = Int(required=False) is_bath_private = Boolean(required=False) lat = String(required=False) lan = String(required=False) amenities = List(String, required=False) description = String(required=False) about_place = String(required=False) guest_access = String(required=False) interaction = String(required=False) other_notes = String(required=False) get_around = String(required=False) for_children = Boolean(required=False) for_infaints = Boolean(required=False) for_pets = Boolean(required=False) smooking = Boolean(required=False) parties = Boolean(required=False) checkin_from = String(required=False) checkin_to = String(required=False) min_stay = Int(required=False) max_stay = Int(required=False) price = Float(required=False) first_offer = Boolean(required=False) weekly_discount = Float(required=False) monthly_discount = Float(required=False) room_type = String(required=False) instant = Boolean(required=False)
class ParameterDomain(ObjectType): class Meta: interfaces = relay.Node, name = String() domain_low = Float() domain_high = Float()
class Arguments: user_id = Int(required=True) annual = Float() alternative = Float() enter_date = types.datetime.Date() is_join = Boolean() level = Int()
class Input: content_id = ID(required=True) score1 = Float(required=True) score2 = Float(required=True) score3 = Float(required=True) recaptcha_token = String(required=True) justification = String(required=False)
class Account(ObjectType): id = Int() name = String() type = Int() type_name = String() balance_usd = Float() balance_rmb = Float() active_entries = List(Entry) @staticmethod def resolve_type_name(parent, _): return parent.type.display_name @staticmethod def resolve_active_entries(parent, _): if 'active_entries' not in g: entries = defaultdict(list) for entry in EntryModel.get_list(current_user): entries[entry.account].append(entry) g.active_entries = entries return g.active_entries[parent] @staticmethod def get_list(): return AccountModel.get_list(current_user)
class BasicTripTimeStats(ObjectType): median = Float() percentile = Float(percentile=Int(required=True)) def resolve_median(parent, info): first_date = util.parse_date(parent["date_str"]) trip_time_median = trip_times.get_cached_trip_times( parent['route_metrics'].agency_id, first_date, "median", parent["start_time"], parent["end_time"]) return trip_time_median.get_value(parent["route_metrics"].route_id, parent["direction_id"], parent["start_stop_id"], parent["end_stop_id"]) def resolve_percentile(parent, info, percentile): first_date = util.parse_date(parent["date_str"]) trip_time_percentile = trip_times.get_cached_trip_times( parent['route_metrics'].agency_id, first_date, "p10-median-p90", parent["start_time"], parent["end_time"]) percentiles_arr = trip_time_percentile.get_value( parent["route_metrics"].route_id, parent["direction_id"], parent["start_stop_id"], parent["end_stop_id"]) if percentiles_arr is None: raise Exception( f"There is no cached data for stops: {parent['start_stop_id']}, {parent['end_stop_id']}." ) if percentile == 10: return percentiles_arr[0] elif percentile == 50: return percentiles_arr[1] elif percentile == 90: return percentiles_arr[2] else: raise Exception( f"User requested a percentile other than [ 10 | 50 | 90 ].")
class BasicWaitTimeStats(ObjectType): median = Float() percentile = Float(percentile=Int(required=True)) probabilityLessThan = Float(minutes=Int(required=True)) def resolve_median(parent, info): first_date = util.parse_date(parent["date_str"]) wait_time_median = wait_times.get_cached_wait_times( parent['route_metrics'].agency_id, first_date, "median", parent["start_time"], parent["end_time"]) if wait_time_median is None: raise Exception( f"There is no cached median for start_stop_id {parent['start_stop_id']} at times {parent['start_time'], parent['end_time']}." ) wait_time_median_value = wait_time_median.get_value( parent["route_metrics"].route_id, parent["direction_id"], parent["start_stop_id"]) if wait_time_median_value is None: raise Exception( f"There is no cached median value returned for start_stop_id {parent['start_stop_id']} at times {parent['start_time'], parent['end_time']}." ) return wait_time_median_value def resolve_percentile(parent, info, percentile): first_date = util.parse_date(parent["date_str"]) wait_time_percentile = wait_times.get_cached_wait_times( parent['route_metrics'].agency_id, first_date, "p10-median-p90", parent["start_time"], parent["end_time"]) percentiles_arr = wait_time_percentile.get_value( parent["route_metrics"].route_id, parent["direction_id"], parent["start_stop_id"]) if percentiles_arr is None: raise Exception( f"There is no cached data for stop: {parent['start_stop_id']}." ) if percentile == 10: return percentiles_arr[0] elif percentile == 50: return percentiles_arr[1] elif percentile == 90: return percentiles_arr[2] else: raise Exception( f"User requested a percentile other than [ 10 | 50 | 90 ].") def resolve_probabilityLessThan(parent, info, minutes): first_date = util.parse_date(parent["date_str"]) wait_time_probability = wait_times.get_cached_wait_times( parent['route_metrics'].agency_id, first_date, "plt5m-30m", parent["start_time"], parent["end_time"]) probabilitys_arr = wait_time_probability.get_value( parent["route_metrics"].route_id, parent["direction_id"], parent["start_stop_id"]) minutes_to_index = {5: 0, 10: 1, 15: 2, 20: 3, 25: 4, 30: 5} if minutes not in minutes_to_index: raise Exception( f'User requested minutes other than [ 5 | 10 | 15 | 20 | 25 | 30 ]' ) return probabilitys_arr[minutes_to_index[minutes]]
class CommunityData(ObjectType): facebook_likes = Int() twitter_followers = Int() reddit_average_posts_48h = Float() reddit_average_comments_48h = Float() reddit_subscribers = Int() reddit_accounts_active_48h = Int() telegram_channel_user_count = Int()
class ProposalAllocatedTime(ObjectType): partner_code = String() partner_name = String() p0 = Float() p1 = Float() p2 = Float() p3 = Float() p4 = Float()
class PriceQuoteType(graphene.ObjectType): subTotal = Float() discountTotal = Float() priceAdjustment = Float() accountBalance = Float() total = Float() discounts = List(DiscountQuoteType) parent = Int()
class Instruments(ObjectType): """ SALT instruments """ bvit = Float() hrs = Float() salticam = Float() rss = Float()
class TransparencyTimeDistribution(ObjectType): """ Types of transparencies that SALT supports """ any = Float() clear = Float() thick_cloud = Float() thin_cloud = Float()
class Arguments: title = String(required=True) description = String(required=True) prep_time = Float(required=True) cook_time = Float(required=True) serving_size = Float(required=True) ingredients = List(String) steps = List(String) active = Boolean()
class Coordinates(ObjectType): lat = Float() long = Float() def resolve_lat(parent, info): return parent.get('lat') def resolve_long(parent, info): return parent.get('long')
class OWMPointWind(ObjectType): speed = Float() deg = Float() def resolve_speed(parent, info): return parent.get('speed') def resolve_deg(parent, info): return parent.get('deg')
class Priorities(ObjectType): """ The SALT observing and allocating priorities """ p0 = Float() p1 = Float() p2 = Float() p3 = Float() p4 = Float()
class DetectorMode(ObjectType): """ The detector mode for some of salt instruments """ drift_scan = Float() frame_transfer = Float() normal = Float() shuffle = Float() slot_mode = Float()
class Resolution(ObjectType): """ The HRS exposure mode """ low_resolution = Float() medium_resolution = Float() high_resolution = Float() high_stability = Float() int_cal_fibre = Float()
class TimeBreakdown(ObjectType): """ The time breakdown """ engineering = Float() idle = Float() lost_to_problems = Float() lost_to_weather = Float() science = Float()
class Film(ObjectType): class Meta: description = "Details of one film" # These fields are all resolved by the Graphene default resolver. film_id = Int(required=True) title = String(required=True) description = String() release_year = Int() rental_duration = Int(required=True) rental_rate = Float(required=True) length = Int() replacement_cost = Float(required=True) last_update = DateTime(required=True) rating = String() # Because these are lists of other types, the default resolver won't be sufficient. actors = List(NonNull(lambda: Actor), required=True) categories = List(Category) # Resolve the `actors` field. Note that the name of this function must match # the name of the field it resolves. # The first argument to this method, `film`, is the "parent" film object. # (You can see where it gets created in the `resolve_film` method of the `Query` class. # # What we're trying to do here is get all the actors for a particular film. # To resolve these actors, we create and execute a SQL query. The query joins # the `film_actor` and `actor` tables and retrieves the (single) row of this # join that contains the `film_id` of the film we're resolving. Note the use of # standard Psycopg2 query parameters to avoid SQL injection issues. # # The `fetchall` method retrieves a list of dictionaries, one for each actor in the result set. # This is the result of having configured our `db_cusor` to use `RealDictCursor`. # Happily, Graphene's default resolver knows how to match up the keys of a dictionary # with the fields of a type, so all the Actor fields will be resolved automatically. def resolve_actors(film, info): db_cursor.execute( """ SELECT actor.actor_id, first_name, last_name, actor.last_update FROM actor INNER JOIN film_actor ON actor.actor_id = film_actor.actor_id WHERE film_actor.film_id = %(film_pk)s """, {"film_pk": film['film_id']}) return [Actor(**row_data) for row_data in db_cursor.fetchall()] # Retrieve the categories for this film. Refer to the documentation for `resolve_actors`, # which is analogous. def resolve_categories(film, info): db_cursor.execute( """ SELECT category.category_id, name FROM category INNER JOIN film_category ON category.category_id = film_category.category_id WHERE film_category.film_id = %(film_pk)s """, {"film_pk": film['film_id']}) return [Category(**row_data) for row_data in db_cursor.fetchall()]
class CalculationType(ObjectType): id = String() # user = String(required=True) creation_date = String(required=True) used_budget = Float(required=True) acting = List(Int) directing = List(Int) companies = List(Int) movies = List(Int) factor = Float() calculated_revenue = Float()
class SeeingTimeDistribution(ObjectType): """ Distribution of time from the maximum seeing request per category. "less_equal_1_dot_5" means seeing between 0 and 1.5 arcseconds, "less_equal_2" means it is between 1.5 and 2 arcseconds, and so forth """ less_equal_1_dot_5 = Float() less_equal_2 = Float() less_equal_2_dot_5 = Float() less_equal_3 = Float() more_than_3 = Float()