diff --git a/app/graph/types/project_group_type.rb b/app/graph/types/project_group_type.rb index aad98569c..bdcd6e0a3 100644 --- a/app/graph/types/project_group_type.rb +++ b/app/graph/types/project_group_type.rb @@ -8,7 +8,6 @@ class ProjectGroupType < DefaultObject field :description, GraphQL::Types::String, null: true field :team_id, GraphQL::Types::Int, null: true field :team, PublicTeamType, null: true - field :medias_count, GraphQL::Types::Int, null: true field :projects, ProjectType.connection_type, null: true end diff --git a/app/models/project_group.rb b/app/models/project_group.rb index 6b5c767b0..78303a9f6 100644 --- a/app/models/project_group.rb +++ b/app/models/project_group.rb @@ -7,10 +7,6 @@ class ProjectGroup < ApplicationRecord belongs_to :team, optional: true has_many :projects, dependent: :nullify - def medias_count - self.projects.map(&:medias_count).sum - end - def project_medias ProjectMedia.joins(:project).where('projects.project_group_id' => self.id) end diff --git a/lib/relay.idl b/lib/relay.idl index 34c73c666..5edaad82c 100644 --- a/lib/relay.idl +++ b/lib/relay.idl @@ -10573,7 +10573,6 @@ type ProjectGroup implements Node { dbid: Int description: String id: ID! - medias_count: Int permissions: String projects( """ diff --git a/public/relay.json b/public/relay.json index 66d151834..8f9e81dfe 100644 --- a/public/relay.json +++ b/public/relay.json @@ -57142,20 +57142,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "medias_count", - "description": null, - "args": [ - - ], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "permissions", "description": null, diff --git a/test/controllers/graphql_controller_4_test.rb b/test/controllers/graphql_controller_4_test.rb index 2bdd4ef54..60dc8f83b 100644 --- a/test/controllers/graphql_controller_4_test.rb +++ b/test/controllers/graphql_controller_4_test.rb @@ -47,7 +47,6 @@ def teardown test "should bulk-send project medias to trash" do @pms.each { |pm| assert_equal CheckArchivedFlags::FlagCodes::NONE, pm.archived } - @ps.each { |p| assert_equal 1, p.reload.medias_count } assert_search_finds_all({ archived: CheckArchivedFlags::FlagCodes::NONE }) assert_search_finds_none({ archived: CheckArchivedFlags::FlagCodes::TRASHED }) assert_equal 0, CheckPusher::Worker.jobs.size @@ -57,7 +56,6 @@ def teardown assert_response :success @pms.each { |pm| assert_equal CheckArchivedFlags::FlagCodes::TRASHED, pm.reload.archived } - @ps.each { |p| assert_equal 0, p.reload.medias_count } assert_search_finds_all({ archived: CheckArchivedFlags::FlagCodes::TRASHED }) assert_search_finds_none({ archived: CheckArchivedFlags::FlagCodes::NONE }) assert_equal 1, CheckPusher::Worker.jobs.size @@ -90,7 +88,6 @@ def teardown Sidekiq::Worker.drain_all sleep 1 @pms.each { |pm| assert_equal CheckArchivedFlags::FlagCodes::TRASHED, pm.reload.archived } - @ps.each { |p| assert_equal 0, p.reload.medias_count } assert_search_finds_all({ archived: CheckArchivedFlags::FlagCodes::TRASHED }) assert_search_finds_none({ archived: CheckArchivedFlags::FlagCodes::NONE }) assert_equal 0, CheckPusher::Worker.jobs.size @@ -100,7 +97,6 @@ def teardown assert_response :success @pms.each { |pm| assert_equal CheckArchivedFlags::FlagCodes::NONE, pm.reload.archived } - @ps.each { |p| assert_equal 1, p.reload.medias_count } assert_search_finds_all({ archived: CheckArchivedFlags::FlagCodes::NONE }) assert_search_finds_none({ archived: CheckArchivedFlags::FlagCodes::TRASHED }) assert_equal 1, CheckPusher::Worker.jobs.size @@ -113,7 +109,6 @@ def teardown Sidekiq::Worker.drain_all sleep 1 @pms.each { |pm| assert_equal CheckArchivedFlags::FlagCodes::TRASHED, pm.reload.archived } - @ps.each { |p| assert_equal 0, p.reload.medias_count } assert_search_finds_all({ archived: CheckArchivedFlags::FlagCodes::TRASHED }) assert_search_finds_none({ archived: CheckArchivedFlags::FlagCodes::NONE }) assert_equal 0, CheckPusher::Worker.jobs.size @@ -123,8 +118,6 @@ def teardown assert_response :success @pms.each { |pm| assert_equal CheckArchivedFlags::FlagCodes::NONE, pm.reload.archived } - @ps.each { |p| assert_equal 0, p.reload.medias_count } - assert_equal @pms.length, add_to.reload.medias_count assert_search_finds_all({ archived: CheckArchivedFlags::FlagCodes::NONE }) assert_search_finds_none({ archived: CheckArchivedFlags::FlagCodes::TRASHED }) assert_equal 2, CheckPusher::Worker.jobs.size @@ -291,17 +284,11 @@ def teardown invalid_id_1 = Base64.encode64("ProjectMedia/0") invalid_id_2 = Base64.encode64("Project/#{pm1.id}") invalid_id_3 = random_string - assert_equal 4, @p1.reload.medias_count - assert_equal 2, @p2.reload.medias_count - assert_equal 0, p4.reload.medias_count ids = [] [@pm1.graphql_id, @pm2.graphql_id, pm1.graphql_id, pm2.graphql_id, invalid_id_1, invalid_id_2, invalid_id_3].each { |id| ids << id } query = 'mutation { updateProjectMedias(input: { clientMutationId: "1", ids: ' + ids.to_json + ', action: "move_to", params: "{\"move_to\": \"' + p4.id.to_s + '\"}" }) { team { dbid } } }' post :create, params: { query: query, team: @t.slug } assert_response :success - assert_equal 0, @p1.reload.medias_count - assert_equal 0, @p2.reload.medias_count - assert_equal 6, p4.reload.medias_count # verify move similar items assert_equal p4.id, t_pm1.reload.project_id assert_equal p4.id, t2_pm1.reload.project_id diff --git a/test/controllers/graphql_controller_test.rb b/test/controllers/graphql_controller_test.rb index 839ddaf9b..786141273 100644 --- a/test/controllers/graphql_controller_test.rb +++ b/test/controllers/graphql_controller_test.rb @@ -397,7 +397,7 @@ def setup p = create_project team: t pm = create_project_media project: p create_comment annotated: pm, annotator: u - query = "query GetById { project(id: \"#{p.id}\") { medias_count, project_medias(first: 1) { edges { node { permissions } } } } }" + query = "query GetById { project(id: \"#{p.id}\") { project_medias(first: 1) { edges { node { permissions } } } } }" post :create, params: { query: query, team: 'team' } assert_response :success assert_not_equal '{}', JSON.parse(@response.body)['data']['project']['project_medias']['edges'][0]['node']['permissions'] diff --git a/test/models/project_group_test.rb b/test/models/project_group_test.rb index 959000629..a8bcf2b6e 100644 --- a/test/models/project_group_test.rb +++ b/test/models/project_group_test.rb @@ -36,28 +36,6 @@ def setup assert_equal [pg], t.reload.project_groups end - test "should have medias count" do - RequestStore.store[:skip_cached_field_update] = false - t = create_team - pg = create_project_group team: t - assert_equal 0, pg.medias_count - p1 = create_project team: t - p1.project_group = pg - p1.save! - assert_equal 0, p1.medias_count - create_project_media project: p1 - assert_equal 1, p1.medias_count - create_project_media project: p1 - assert_equal 2, p1.medias_count - p2 = create_project team: t - p2.project_group = pg - p2.save! - assert_equal 0, p2.medias_count - create_project_media project: p2 - assert_equal 1, p2.medias_count - assert_equal 3, pg.reload.medias_count - end - test "should have project medias" do t = create_team pg = create_project_group team: t