Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-28 12:10:32 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-28 12:10:32 +0300
commitc4b69460e8dd4921eb20fa78b47ceff294d725dc (patch)
tree9be3f5c3913ead9eeb5f183ac7a163b193412967 /lib/gitlab
parent540c69c58c9e60f2d9b47987afe5e020593d39ac (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/anonymous_session.rb17
-rw-r--r--lib/gitlab/redis/shared_state.rb2
-rw-r--r--lib/gitlab/usage_data_counters/editor_unique_counter.rb19
-rw-r--r--lib/gitlab/usage_data_counters/known_events.yml15
4 files changed, 37 insertions, 16 deletions
diff --git a/lib/gitlab/anonymous_session.rb b/lib/gitlab/anonymous_session.rb
index 148b6d3310d..911825eef3a 100644
--- a/lib/gitlab/anonymous_session.rb
+++ b/lib/gitlab/anonymous_session.rb
@@ -2,35 +2,34 @@
module Gitlab
class AnonymousSession
- def initialize(remote_ip, session_id: nil)
+ def initialize(remote_ip)
@remote_ip = remote_ip
- @session_id = session_id
end
- def store_session_id_per_ip
+ def count_session_ip
Gitlab::Redis::SharedState.with do |redis|
redis.pipelined do
- redis.sadd(session_lookup_name, session_id)
+ redis.incr(session_lookup_name)
redis.expire(session_lookup_name, 24.hours)
end
end
end
- def stored_sessions
+ def session_count
Gitlab::Redis::SharedState.with do |redis|
- redis.scard(session_lookup_name)
+ redis.get(session_lookup_name).to_i
end
end
- def cleanup_session_per_ip_entries
+ def cleanup_session_per_ip_count
Gitlab::Redis::SharedState.with do |redis|
- redis.srem(session_lookup_name, session_id)
+ redis.del(session_lookup_name)
end
end
private
- attr_reader :remote_ip, :session_id
+ attr_reader :remote_ip
def session_lookup_name
@session_lookup_name ||= "#{Gitlab::Redis::SharedState::IP_SESSIONS_LOOKUP_NAMESPACE}:#{remote_ip}"
diff --git a/lib/gitlab/redis/shared_state.rb b/lib/gitlab/redis/shared_state.rb
index 8ab53700932..2848c9f0b59 100644
--- a/lib/gitlab/redis/shared_state.rb
+++ b/lib/gitlab/redis/shared_state.rb
@@ -9,7 +9,7 @@ module Gitlab
SESSION_NAMESPACE = 'session:gitlab'
USER_SESSIONS_NAMESPACE = 'session:user:gitlab'
USER_SESSIONS_LOOKUP_NAMESPACE = 'session:lookup:user:gitlab'
- IP_SESSIONS_LOOKUP_NAMESPACE = 'session:lookup:ip:gitlab'
+ IP_SESSIONS_LOOKUP_NAMESPACE = 'session:lookup:ip:gitlab2'
DEFAULT_REDIS_SHARED_STATE_URL = 'redis://localhost:6382'
REDIS_SHARED_STATE_CONFIG_ENV_VAR_NAME = 'GITLAB_REDIS_SHARED_STATE_CONFIG_FILE'
diff --git a/lib/gitlab/usage_data_counters/editor_unique_counter.rb b/lib/gitlab/usage_data_counters/editor_unique_counter.rb
index 251c83d3eed..a07840fd9bd 100644
--- a/lib/gitlab/usage_data_counters/editor_unique_counter.rb
+++ b/lib/gitlab/usage_data_counters/editor_unique_counter.rb
@@ -3,9 +3,10 @@
module Gitlab
module UsageDataCounters
module EditorUniqueCounter
- EDIT_BY_SNIPPET_EDITOR = :edit_by_snippet_editor
- EDIT_BY_SFE = :edit_by_sfe
- EDIT_BY_WEB_IDE = :edit_by_web_ide
+ EDIT_BY_SNIPPET_EDITOR = 'g_edit_by_snippet_ide'
+ EDIT_BY_SFE = 'g_edit_by_sfe'
+ EDIT_BY_WEB_IDE = 'g_edit_by_web_ide'
+ EDIT_CATEGORY = 'ide_edit'
class << self
def track_web_ide_edit_action(author:, time: Time.zone.now)
@@ -32,16 +33,22 @@ module Gitlab
count_unique(EDIT_BY_SNIPPET_EDITOR, date_from, date_to)
end
+ def count_edit_using_editor(date_from:, date_to:)
+ events = Gitlab::UsageDataCounters::HLLRedisCounter.events_for_category(EDIT_CATEGORY)
+ count_unique(events, date_from, date_to)
+ end
+
private
def track_unique_action(action, author, time)
return unless Feature.enabled?(:track_editor_edit_actions)
+ return unless author
- Gitlab::UsageDataCounters::TrackUniqueActions.track_action(action: action, author_id: author.id, time: time)
+ Gitlab::UsageDataCounters::HLLRedisCounter.track_event(author.id, action, time)
end
- def count_unique(action, date_from, date_to)
- Gitlab::UsageDataCounters::TrackUniqueActions.count_unique(action: action, date_from: date_from, date_to: date_to)
+ def count_unique(actions, date_from, date_to)
+ Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(event_names: actions, start_date: date_from, end_date: date_to)
end
end
end
diff --git a/lib/gitlab/usage_data_counters/known_events.yml b/lib/gitlab/usage_data_counters/known_events.yml
index a910f998d86..feda3aeedfe 100644
--- a/lib/gitlab/usage_data_counters/known_events.yml
+++ b/lib/gitlab/usage_data_counters/known_events.yml
@@ -69,3 +69,18 @@
category: analytics
redis_slot: analytics
aggregation: weekly
+- name: g_edit_by_web_ide
+ category: ide_edit
+ redis_slot: edit
+ expiry: 29
+ aggregation: daily
+- name: g_edit_by_sfe
+ category: ide_edit
+ redis_slot: edit
+ expiry: 29
+ aggregation: daily
+- name: g_edit_by_snippet_ide
+ category: ide_edit
+ redis_slot: edit
+ expiry: 29
+ aggregation: daily