Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter articles by "created" date. #2208

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/graph/types/team_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ def tipline_requests(from_timestamp:, to_timestamp:)
argument :tags, [GraphQL::Types::String, null: true], required: false, camelize: false
argument :language, [GraphQL::Types::String, null: true], required: false, camelize: false
argument :updated_at, GraphQL::Types::String, required: false, camelize: false # JSON
argument :created_at, GraphQL::Types::String, required: false, camelize: false # JSON
argument :text, GraphQL::Types::String, required: false, camelize: false # Search by text
argument :standalone, GraphQL::Types::Boolean, required: false, camelize: false # Not applied to any item (fact-checks only)
argument :publisher_ids, [GraphQL::Types::Int, null: true], required: false, camelize: false
Expand Down Expand Up @@ -347,6 +348,7 @@ def articles(**args)
argument :tags, [GraphQL::Types::String, null: true], required: false, camelize: false
argument :language, [GraphQL::Types::String, null: true], required: false, camelize: false
argument :updated_at, GraphQL::Types::String, required: false, camelize: false # JSON
argument :created_at, GraphQL::Types::String, required: false, camelize: false # JSON
argument :text, GraphQL::Types::String, required: false, camelize: false # Search by text
argument :standalone, GraphQL::Types::Boolean, required: false, camelize: false # Not applied to any item (fact-checks only)
argument :publisher_ids, [GraphQL::Types::Int, null: true], required: false, camelize: false
Expand Down
2 changes: 2 additions & 0 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ def filtered_explainers(filters = {})

# Filter by date
query = query.where(updated_at: Range.new(*format_times_search_range_filter(JSON.parse(filters[:updated_at]), nil))) unless filters[:updated_at].blank?
query = query.where(created_at: Range.new(*format_times_search_range_filter(JSON.parse(filters[:created_at]), nil))) unless filters[:created_at].blank?

# Filter by trashed
query = query.where(trashed: !!filters[:trashed])
Expand Down Expand Up @@ -529,6 +530,7 @@ def filtered_fact_checks(filters = {})

# Filter by date
query = query.where('fact_checks.updated_at' => Range.new(*format_times_search_range_filter(JSON.parse(filters[:updated_at]), nil))) unless filters[:updated_at].blank?
query = query.where('fact_checks.created_at' => Range.new(*format_times_search_range_filter(JSON.parse(filters[:created_at]), nil))) unless filters[:created_at].blank?

# Filter by publisher
query = query.where('fact_checks.publisher_id' => filters[:publisher_ids].to_a.map(&:to_i)) unless filters[:publisher_ids].blank?
Expand Down
3 changes: 2 additions & 1 deletion lib/relay.idl
Original file line number Diff line number Diff line change
Expand Up @@ -13187,6 +13187,7 @@ type Team implements Node {
Returns the elements in the list that come before the specified cursor.
"""
before: String
created_at: String

"""
Returns the first _n_ elements from the list.
Expand All @@ -13213,7 +13214,7 @@ type Team implements Node {
updated_at: String
user_ids: [Int]
): ArticleUnionConnection
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
articles_count(article_type: String, created_at: 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(enableLanguageDetection: Boolean, enableLinkShortening: Boolean, maxNumberOfWords: Int, searchText: String!, shouldRestrictByLanguage: Boolean, threshold: Float, utmCode: String): [TiplineSearchResult!]
Expand Down
24 changes: 24 additions & 0 deletions public/relay.json
Original file line number Diff line number Diff line change
Expand Up @@ -69301,6 +69301,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "created_at",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "text",
"description": null,
Expand Down Expand Up @@ -69494,6 +69506,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "created_at",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "text",
"description": null,
Expand Down
Loading