diff --git a/Gemfile b/Gemfile index 7dcc3fbf93cb7a8664ca5a0ad043559316224e11..08d50bfcf27d091f67ecd3fcab29c0c0703afc72 100644 --- a/Gemfile +++ b/Gemfile @@ -377,7 +377,9 @@ gem 'rack-proxy', '~> 0.7.7', feature_category: :shared # rubocop:todo Gemfile/M gem 'cssbundling-rails', '1.4.3', feature_category: :shared # rubocop:todo Gemfile/MissingFeatureCategory -- https://gitlab.com/gitlab-org/gitlab/-/issues/581839 gem 'terser', '1.0.2', feature_category: :shared # rubocop:todo Gemfile/MissingFeatureCategory -- https://gitlab.com/gitlab-org/gitlab/-/issues/581839 -gem 'click_house-client', '0.8.4', feature_category: :database +gem 'click_house-client', git: 'https://gitlab.com/gitlab-org/ruby/gems/clickhouse-client.git', branch: '17-add-date-typecasters-part-2', # rubocop:disable Cop/GemFetcher -- tmp + feature_category: :database +# gem 'click_house-client', '0.8.4', feature_category: :database gem 'addressable', '~> 2.8', feature_category: :shared # rubocop:todo Gemfile/MissingFeatureCategory -- https://gitlab.com/gitlab-org/gitlab/-/issues/581839 gem 'gon', '~> 6.5.0', feature_category: :shared # rubocop:todo Gemfile/MissingFeatureCategory -- https://gitlab.com/gitlab-org/gitlab/-/issues/581839 gem 'request_store', '~> 1.7.0', feature_category: :shared # rubocop:todo Gemfile/MissingFeatureCategory -- https://gitlab.com/gitlab-org/gitlab/-/issues/581839 diff --git a/Gemfile.checksum b/Gemfile.checksum index 2ea5a4bfd2f168ab226d3fcc10c9e1f2bbe0a210..29d5fa35e0e3231524dec6ff6fc71c82f311c857 100644 --- a/Gemfile.checksum +++ b/Gemfile.checksum @@ -82,7 +82,6 @@ {"name":"citrus","version":"3.0.2","platform":"ruby","checksum":"4ec2412fc389ad186735f4baee1460f7900a8e130ffe3f216b30d4f9c684f650"}, {"name":"claide","version":"1.1.0","platform":"ruby","checksum":"6d3c5c089dde904d96aa30e73306d0d4bd444b1accb9b3125ce14a3c0183f82e"}, {"name":"claide-plugins","version":"0.9.2","platform":"ruby","checksum":"c7ea78bc067ab23bce8515497cdcdcb8f01c86dadfbe13c44644e382922c1c2e"}, -{"name":"click_house-client","version":"0.8.4","platform":"ruby","checksum":"8278a6319fd30e8cb5dd4e8ada247a16819a6d4f3548cb0efed6c188ee5dfd18"}, {"name":"coderay","version":"1.1.3","platform":"ruby","checksum":"dc530018a4684512f8f38143cd2a096c9f02a1fc2459edcfe534787a7fc77d4b"}, {"name":"coercible","version":"1.0.0","platform":"ruby","checksum":"5081ad24352cc8435ce5472bc2faa30260c7ea7f2102cc6a9f167c4d9bffaadc"}, {"name":"colored2","version":"3.1.2","platform":"ruby","checksum":"b13c2bd7eeae2cf7356a62501d398e72fde78780bd26aec6a979578293c28b4a"}, diff --git a/Gemfile.lock b/Gemfile.lock index d808c4d21015934364953dd5f6e1b1191f3b39a5..ac02acbc2f46feb0668922e166d3ab54b8de0293 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,14 @@ +GIT + remote: https://gitlab.com/gitlab-org/ruby/gems/clickhouse-client.git + revision: 59c231754f5a5da3e6697f57f478f62d0bc7f4b7 + branch: 17-add-date-typecasters-part-2 + specs: + click_house-client (0.8.6) + activerecord (>= 7.0, < 9.0) + activesupport (>= 7.0, < 9.0) + addressable (~> 2.8) + json (~> 2.7) + PATH remote: gems/activerecord-gitlab specs: @@ -435,11 +446,6 @@ GEM cork nap open4 (~> 1.3) - click_house-client (0.8.4) - activerecord (>= 7.0, < 9.0) - activesupport (>= 7.0, < 9.0) - addressable (~> 2.8) - json (~> 2.7) coderay (1.1.3) coercible (1.0.0) descendants_tracker (~> 0.0.1) @@ -2123,7 +2129,7 @@ DEPENDENCIES carrierwave (~> 1.3) charlock_holmes (~> 0.7.9) circuitbox (= 2.0.0) - click_house-client (= 0.8.4) + click_house-client! commonmarker (~> 0.23.10) concurrent-ruby (~> 1.1) connection_pool (~> 2.5.3) diff --git a/Gemfile.next.checksum b/Gemfile.next.checksum index 2ea5a4bfd2f168ab226d3fcc10c9e1f2bbe0a210..29d5fa35e0e3231524dec6ff6fc71c82f311c857 100644 --- a/Gemfile.next.checksum +++ b/Gemfile.next.checksum @@ -82,7 +82,6 @@ {"name":"citrus","version":"3.0.2","platform":"ruby","checksum":"4ec2412fc389ad186735f4baee1460f7900a8e130ffe3f216b30d4f9c684f650"}, {"name":"claide","version":"1.1.0","platform":"ruby","checksum":"6d3c5c089dde904d96aa30e73306d0d4bd444b1accb9b3125ce14a3c0183f82e"}, {"name":"claide-plugins","version":"0.9.2","platform":"ruby","checksum":"c7ea78bc067ab23bce8515497cdcdcb8f01c86dadfbe13c44644e382922c1c2e"}, -{"name":"click_house-client","version":"0.8.4","platform":"ruby","checksum":"8278a6319fd30e8cb5dd4e8ada247a16819a6d4f3548cb0efed6c188ee5dfd18"}, {"name":"coderay","version":"1.1.3","platform":"ruby","checksum":"dc530018a4684512f8f38143cd2a096c9f02a1fc2459edcfe534787a7fc77d4b"}, {"name":"coercible","version":"1.0.0","platform":"ruby","checksum":"5081ad24352cc8435ce5472bc2faa30260c7ea7f2102cc6a9f167c4d9bffaadc"}, {"name":"colored2","version":"3.1.2","platform":"ruby","checksum":"b13c2bd7eeae2cf7356a62501d398e72fde78780bd26aec6a979578293c28b4a"}, diff --git a/Gemfile.next.lock b/Gemfile.next.lock index d808c4d21015934364953dd5f6e1b1191f3b39a5..ac02acbc2f46feb0668922e166d3ab54b8de0293 100644 --- a/Gemfile.next.lock +++ b/Gemfile.next.lock @@ -1,3 +1,14 @@ +GIT + remote: https://gitlab.com/gitlab-org/ruby/gems/clickhouse-client.git + revision: 59c231754f5a5da3e6697f57f478f62d0bc7f4b7 + branch: 17-add-date-typecasters-part-2 + specs: + click_house-client (0.8.6) + activerecord (>= 7.0, < 9.0) + activesupport (>= 7.0, < 9.0) + addressable (~> 2.8) + json (~> 2.7) + PATH remote: gems/activerecord-gitlab specs: @@ -435,11 +446,6 @@ GEM cork nap open4 (~> 1.3) - click_house-client (0.8.4) - activerecord (>= 7.0, < 9.0) - activesupport (>= 7.0, < 9.0) - addressable (~> 2.8) - json (~> 2.7) coderay (1.1.3) coercible (1.0.0) descendants_tracker (~> 0.0.1) @@ -2123,7 +2129,7 @@ DEPENDENCIES carrierwave (~> 1.3) charlock_holmes (~> 0.7.9) circuitbox (= 2.0.0) - click_house-client (= 0.8.4) + click_house-client! commonmarker (~> 0.23.10) concurrent-ruby (~> 1.1) connection_pool (~> 2.5.3) diff --git a/app/services/ci/collect_time_series_pipeline_analytics_service.rb b/app/services/ci/collect_time_series_pipeline_analytics_service.rb index 206d56e0ad44792c3d08854a0591790d455e03b8..8243db5ea5664895aafa3436710557658e46e666 100644 --- a/app/services/ci/collect_time_series_pipeline_analytics_service.rb +++ b/app/services/ci/collect_time_series_pipeline_analytics_service.rb @@ -66,7 +66,7 @@ def calculate_time_series_count(query, time_series) all_count_result = execute_select_query(all_query) .to_h do |entry| - [parse_in_utc(entry[:timestamp]), { count: { any: entry[:all] } }] + [to_utc(entry[:timestamp]), { count: { any: entry[:all] } }] end time_series.deep_merge!(all_count_result) @@ -85,7 +85,7 @@ def calculate_time_series_status_group_counts(query, time_series) # such as `{ Time.utc(2023, 1, 1) => { count: { success: 1, failed: 0, other: 1, any: 3 } }` counts_by_timestamp = execute_select_query(query) - .group_by { |entry| parse_in_utc(entry[:timestamp]) } + .group_by { |entry| to_utc(entry[:timestamp]) } .transform_values { |counts_by_status| { count: group_and_sum_counts(counts_by_status) } } time_series.deep_merge!(counts_by_timestamp) @@ -101,7 +101,7 @@ def calculate_time_series_duration_percentiles(query, time_series) time_series.deep_merge!( execute_select_query(duration_by_date_query) - .group_by { |entry| parse_in_utc(entry[:timestamp]) } + .group_by { |entry| to_utc(entry[:timestamp]) } .transform_values { |hash| hash.sole.excluding(:timestamp) } # Keep only percentiles .transform_values do |percentiles_by_date| { duration_statistics: round_percentiles(percentiles_by_date) } @@ -151,11 +151,7 @@ def round_percentiles(percentiles_by_date) end def to_utc(timestamp) - timestamp.change(offset: 0).utc - end - - def parse_in_utc(timestamp) - to_utc(Time.parse(timestamp)) # rubocop:disable Rails/TimeZone -- false positive, to_utc takes care of this + timestamp.to_datetime.change(offset: 0).utc end def group_and_sum_counts(counts_by_status_and_time) diff --git a/ee/app/services/analytics/ai_analytics/last_code_suggestion_usage_service.rb b/ee/app/services/analytics/ai_analytics/last_code_suggestion_usage_service.rb index 63bdf390ffc5c44051804168a1fddd0602bb05f4..1031e57c7a2a760d03fdd38a803d322ae299af77 100644 --- a/ee/app/services/analytics/ai_analytics/last_code_suggestion_usage_service.rb +++ b/ee/app/services/analytics/ai_analytics/last_code_suggestion_usage_service.rb @@ -38,7 +38,7 @@ def last_usages end data.to_h do |row| - [row['user_id'], DateTime.parse(row['last_used_at'])] + [row['user_id'], row['last_used_at']] end end diff --git a/spec/db/click_house/migrate/20251023184515_backfill_code_suggestion_events_daily_new_spec.rb b/spec/db/click_house/migrate/20251023184515_backfill_code_suggestion_events_daily_new_spec.rb index 0e7f68b4a2b525c4881ee1fdbe6031ba2735d3be..8f8109d2f05b04c6a7ced7e366321ee09caa025a 100644 --- a/spec/db/click_house/migrate/20251023184515_backfill_code_suggestion_events_daily_new_spec.rb +++ b/spec/db/click_house/migrate/20251023184515_backfill_code_suggestion_events_daily_new_spec.rb @@ -39,7 +39,7 @@ expect(results).to contain_exactly( hash_including( - 'date' => '2023-01-15', + 'date' => Date.parse('2023-01-15'), 'user_id' => 1, 'event' => 1, 'language' => 'ruby', @@ -48,7 +48,7 @@ 'occurrences' => 2 ), hash_including( - 'date' => '2023-01-15', + 'date' => Date.parse('2023-01-15'), 'user_id' => 1, 'event' => 2, 'language' => 'go', @@ -57,7 +57,7 @@ 'occurrences' => 1 ), hash_including( - 'date' => '2024-01-16', + 'date' => Date.parse('2024-01-16'), 'user_id' => 1, 'event' => 2, 'language' => 'python', @@ -66,7 +66,7 @@ 'occurrences' => 2 ), hash_including( - 'date' => '2025-01-31', + 'date' => Date.parse('2025-01-31'), 'user_id' => 1, 'event' => 2, 'language' => 'rust', diff --git a/spec/lib/click_house/finders/ci/finished_builds_finder_spec.rb b/spec/lib/click_house/finders/ci/finished_builds_finder_spec.rb index 9dc6a65ed333323744a6b11b1a241c2e00526a6c..c277238510d9f2c93635216c270ee2f257e39ab0 100644 --- a/spec/lib/click_house/finders/ci/finished_builds_finder_spec.rb +++ b/spec/lib/click_house/finders/ci/finished_builds_finder_spec.rb @@ -255,7 +255,7 @@ it "calculates rate correctly" do is_expected.not_to be_empty - expect(result.first.fetch("rate_of_#{status}")).to be_a(Integer) + expect(result.first.fetch("rate_of_#{status}")).to be_a(Float) end end