Skip to content

Commit

Permalink
Merge branch 'develop' into CV2-6152-apply-item-status-to-matched-items
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Feb 13, 2025
2 parents 5f38ce3 + a7ccd92 commit a88d511
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 25 deletions.
3 changes: 2 additions & 1 deletion app/graph/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ def me

def team(id: nil, slug: nil, random: nil)
tid = id.to_i
team = nil
unless slug.blank?
team = Team.where(slug: slug).first
tid = team.id unless team.nil?
end
team.reload if random
team.reload if team && random
tid = Team.current&.id || User.current&.teams&.first&.id if tid === 0
GraphqlCrudOperations.load_if_can(Team, tid.to_i, context)
end
Expand Down
4 changes: 3 additions & 1 deletion app/models/concerns/alegre_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,10 @@ def delete_package_audio(project_media, _field, params)
end

def store_package(project_media, field, params={})
type = get_type(project_media)
return if type.nil?
generic_package(project_media, field).merge(
self.send("store_package_#{get_type(project_media)}", project_media, field, params)
self.send("store_package_#{type}", project_media, field, params)
)
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def filtered_explainers(filters = {})
query = query.where(user_id: filters[:user_ids].to_a.map(&:to_i)) unless filters[:user_ids].blank?

# 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('explainers.created_at != explainers.updated_at').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
Expand Down Expand Up @@ -529,7 +529,7 @@ def filtered_fact_checks(filters = {})
query = query.where('fact_checks.user_id' => filters[:user_ids].to_a.map(&:to_i)) unless filters[:user_ids].blank?

# 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 != fact_checks.updated_at').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
Expand Down
26 changes: 5 additions & 21 deletions pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
## Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context – why has this been changed/fixed.
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context, type of change (bug fix, performance, feature, etc.) and things to pay attention to during review.

References: TICKET-ID, TICKET-ID, …
References: TICKET-ID-1, TICKET-ID-2, …, TICKET-ID-N

## How has this been tested?
## How to test?

Please describe the tests that you ran to verify your changes. Provide instructions so we can verify the changes. Please describe whether or not you implemented automated tests.

## Things to pay attention to during code review

Please describe parts of the change that require extra attention during code review, for example:

- File FFFF, line LL: This refactoring does this and this. Is it consistent with how it’s implemented elsewhere?
- Etc.
Please describe how to test the changes (manually and/or automatically).

## Checklist

- [ ] I have performed a self-review of my own code
- [ ] I have added unit and feature tests, if the PR implements a new feature or otherwise would benefit from additional testing
- [ ] I have added regression tests, if the PR fixes a bug
- [ ] I have added logging, exception reporting, and custom tracing with any additional information required for debugging
- [ ] I considered secure coding practices when writing this code. Any security concerns are noted above.
- [ ] I have commented my code in hard-to-understand areas, if any
- [ ] I have made needed changes to the README
- [ ] My changes generate no new warnings
- [ ] If I added a third party module, I included a rationale for doing so and followed our current [guidelines](https://meedan.atlassian.net/wiki/spaces/ENG/overview#Choose-the-%E2%80%9Cright%E2%80%9D-3rd-party-module)

- [ ] I have performed a self-review of my code and ensured that it is safe and runnable, that code coverage has not decreased, and that there are no new Code Climate issues. I have also followed [Meedan's internal coding guidelines](https://meedan.atlassian.net/wiki/spaces/ENG/pages/1309605889/Coding+guidelines).
20 changes: 20 additions & 0 deletions test/controllers/graphql_controller_11_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,24 @@ def teardown
assert_equal pm1.created_at.to_i, response['media_cluster_origin_timestamp']
assert_equal CheckMediaClusterOrigins::OriginCodes::USER_ADDED, response['media_cluster_origin']
end

test "should not crash if workspace doesn't exist" do
t = create_team
u = create_user
create_team_user team: t, user: u, role: 'admin'
authenticate_with_user(u)
t.delete

query = <<~GRAPHQL
query {
team(slug: "#{t.slug}", random: "123456") {
name
}
}
GRAPHQL

post :create, params: { query: query, team: t.slug }
assert_response :success
assert_match /ActiveRecord::RecordNotFound/, @response.body
end
end
7 changes: 7 additions & 0 deletions test/models/bot/alegre_4_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,11 @@ def teardown
end
Bot::Alegre.unstub.stubs(:request)
end

test "should not try to store package for blank item" do
pm = create_project_media media: Blank.create!
assert_nothing_raised do
Bot::Alegre.store_package(pm, 'title')
end
end
end

0 comments on commit a88d511

Please sign in to comment.