Skip to content

Commit

Permalink
[WIP] Ticket CV2-5919: GraphQL API structure
Browse files Browse the repository at this point in the history
  • Loading branch information
caiosba committed Jan 19, 2025
1 parent c115a52 commit 421c426
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 3 deletions.
10 changes: 8 additions & 2 deletions app/graph/types/team_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,16 @@ def statistics(period:, language: nil, platform: nil)

field :bot_query, [TiplineSearchResultType], null: true do
argument :search_text, GraphQL::Types::String, required: true
argument :threshold, GraphQL::Types::Float, required: false
argument :max_number_of_words, GraphQL::Types::Int, required: false
argument :enable_language_detection, GraphQL::Types::Boolean, required: false
argument :should_restrict_by_language, GraphQL::Types::Boolean, required: false
argument :enable_link_shortening, GraphQL::Types::Boolean, required: false
argument :utm_code, GraphQL::Types::String, required: false
end

def bot_query(search_text:)
return nil unless User.current&.is_admin
def bot_query(search_text:, threshold: nil, max_number_of_words: nil, enable_language_detection: nil, should_restrict_by_language: nil, enable_link_shortening: nil, utm_code: nil)
return nil unless User.current&.is_admin # Feature flag

results = object.search_for_similar_articles(search_text)
results.map(&:as_tipline_search_result)
Expand Down
2 changes: 1 addition & 1 deletion lib/relay.idl
Original file line number Diff line number Diff line change
Expand Up @@ -13208,7 +13208,7 @@ type Team implements Node {
articles_count(article_type: String, imported: Boolean, language: [String], publisher_ids: [Int], rating: [String], report_status: [String], standalone: Boolean, tags: [String], target_id: Int, text: String, trashed: Boolean = false, updated_at: String, user_ids: [Int]): Int
available_newsletter_header_types: JsonStringType
avatar: String
bot_query(searchText: String!): [TiplineSearchResult!]
bot_query(enableLanguageDetection: Boolean, enableLinkShortening: Boolean, maxNumberOfWords: Int, searchText: String!, shouldRestrictByLanguage: Boolean, threshold: Float, utmCode: String): [TiplineSearchResult!]
check_search_spam: CheckSearch
check_search_trash: CheckSearch
check_search_unconfirmed: CheckSearch
Expand Down
82 changes: 82 additions & 0 deletions public/relay.json
Original file line number Diff line number Diff line change
Expand Up @@ -48310,6 +48310,16 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "Float",
"description": "Represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "GenerateTwoFactorBackupCodesInput",
Expand Down Expand Up @@ -69536,6 +69546,78 @@
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "threshold",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Float",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "maxNumberOfWords",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "enableLanguageDetection",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "shouldRestrictByLanguage",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "enableLinkShortening",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "utmCode",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
Expand Down

0 comments on commit 421c426

Please sign in to comment.