proactive_support 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.ruby-gemset +1 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +41 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +23 -0
- data/app/helpers/proactive_support/flags_helper.rb +17 -0
- data/app/models/proactive_support/flag.rb +13 -0
- data/app/models/proactive_support/note.rb +11 -0
- data/bin/rails +12 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20160503172810_create_proactive_support_notes.rb +15 -0
- data/db/migrate/20160503172811_create_proactive_support_flags.rb +24 -0
- data/example/app/controllers/proactive_support/application_controller.rb +4 -0
- data/example/app/controllers/proactive_support/notes_controller.rb +62 -0
- data/example/app/helpers/proactive_support/application_helper.rb +4 -0
- data/example/app/helpers/proactive_support/notes_helper.rb +4 -0
- data/example/app/views/layouts/proactive_support/application.html.erb +14 -0
- data/example/app/views/proactive_support/notes/_form.html.erb +37 -0
- data/example/app/views/proactive_support/notes/edit.html.erb +6 -0
- data/example/app/views/proactive_support/notes/index.html.erb +35 -0
- data/example/app/views/proactive_support/notes/new.html.erb +5 -0
- data/example/app/views/proactive_support/notes/show.html.erb +29 -0
- data/lib/proactive-support.rb +1 -0
- data/lib/proactive_support/engine.rb +9 -0
- data/lib/proactive_support/mgmt/flags.rb +48 -0
- data/lib/proactive_support/mgmt/notes.rb +20 -0
- data/lib/proactive_support/version.rb +3 -0
- data/lib/proactive_support.rb +45 -0
- data/lib/tasks/proactive_support_tasks.rake +15 -0
- data/proactive_support.gemspec +22 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +29 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- metadata +144 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: b39f93d0821904ce90f8701ebddb01815ab34741
|
|
4
|
+
data.tar.gz: d490eddef2a9cb231cefa69ebf3212d060c2de70
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8fdcbe8fef8f98911db3ef35522cb5a21a7531355a5a6949f0438d2befa8bfbbeab2f60eed7c62031ee8226181ada3b931bc5044bb8ee86f81fe184a4b27fd4f
|
|
7
|
+
data.tar.gz: 613a6b7f5a1577d76d1d7e94d7ca225d86e167469cf23a78fca8efa441019caafc9fda1d5146bfe57ddf696a0244191cd7bd92f24fbe1a284f477929f0bfa788
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
proactive_support
|
data/Gemfile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
# Declare your gem's dependencies in proactive_support.gemspec.
|
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
|
5
|
+
# development dependencies will be added by default to the :development group.
|
|
6
|
+
gemspec
|
|
7
|
+
|
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
|
11
|
+
# your gem to rubygems.org.
|
|
12
|
+
|
|
13
|
+
# To use debugger
|
|
14
|
+
# gem 'debugger'
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
proactive_support (0.0.1)
|
|
5
|
+
activerecord (>= 3)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activemodel (4.2.6)
|
|
11
|
+
activesupport (= 4.2.6)
|
|
12
|
+
builder (~> 3.1)
|
|
13
|
+
activerecord (4.2.6)
|
|
14
|
+
activemodel (= 4.2.6)
|
|
15
|
+
activesupport (= 4.2.6)
|
|
16
|
+
arel (~> 6.0)
|
|
17
|
+
activesupport (4.2.6)
|
|
18
|
+
i18n (~> 0.7)
|
|
19
|
+
json (~> 1.7, >= 1.7.7)
|
|
20
|
+
minitest (~> 5.1)
|
|
21
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
22
|
+
tzinfo (~> 1.1)
|
|
23
|
+
arel (6.0.3)
|
|
24
|
+
builder (3.2.2)
|
|
25
|
+
i18n (0.7.0)
|
|
26
|
+
json (1.8.3)
|
|
27
|
+
minitest (5.8.4)
|
|
28
|
+
sqlite3 (1.3.11)
|
|
29
|
+
thread_safe (0.3.5)
|
|
30
|
+
tzinfo (1.2.2)
|
|
31
|
+
thread_safe (~> 0.1)
|
|
32
|
+
|
|
33
|
+
PLATFORMS
|
|
34
|
+
ruby
|
|
35
|
+
|
|
36
|
+
DEPENDENCIES
|
|
37
|
+
proactive_support!
|
|
38
|
+
sqlite3
|
|
39
|
+
|
|
40
|
+
BUNDLED WITH
|
|
41
|
+
1.11.2
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2016 YOURNAME
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'ProactiveSupport'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
|
18
|
+
load 'rails/tasks/engine.rake'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Bundler::GemHelper.install_tasks
|
|
23
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module ProactiveSupport
|
|
2
|
+
module FlagsHelper
|
|
3
|
+
def get_flag_groupings(customer_id, filter_transients = true)
|
|
4
|
+
flags = {}
|
|
5
|
+
ar = ::ProactiveSupport::Flag.where(customer_id: customer_id, is_active: true)
|
|
6
|
+
ar = ar.filter_transients if filter_transients
|
|
7
|
+
ar.each do |f|
|
|
8
|
+
flags[f.level] ||= {}
|
|
9
|
+
flags[f.level][f.source] ||= {}
|
|
10
|
+
flags[f.level][f.source][f.identifier] ||= {message: f.message, count: 0, transients: 0}
|
|
11
|
+
flags[f.level][f.source][f.identifier][:count] += 1
|
|
12
|
+
flags[f.level][f.source][f.identifier][:transients] += 1 if f.is_transient
|
|
13
|
+
end
|
|
14
|
+
Hash[flags.sort.reverse] # errors first...
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module ProactiveSupport
|
|
2
|
+
class Flag < ::ActiveRecord::Base
|
|
3
|
+
self.table_name = 'proactive_support_flags' # Needed for activerecord-jdbc-adapter
|
|
4
|
+
|
|
5
|
+
belongs_to :customer
|
|
6
|
+
|
|
7
|
+
validates_presence_of :customer_id, :source, :identifier, :message
|
|
8
|
+
serialize :filter, HashWithIndifferentAccess
|
|
9
|
+
serialize :debug_params, HashWithIndifferentAccess
|
|
10
|
+
|
|
11
|
+
scope :filter_transients, -> { where("is_transient = 0 OR (is_transient = 1 AND UNIX_TIMESTAMP(last_triggered_at) > #{(::Time.now - ::ProactiveSupport.configuration.transient_expiration).to_i})") }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module ProactiveSupport
|
|
2
|
+
class Note < ::ActiveRecord::Base
|
|
3
|
+
self.table_name = 'proactive_support_notes' # Needed for activerecord-jdbc-adapter
|
|
4
|
+
|
|
5
|
+
belongs_to :customer
|
|
6
|
+
belongs_to :user
|
|
7
|
+
|
|
8
|
+
validates_presence_of :customer_id
|
|
9
|
+
validates_presence_of :title
|
|
10
|
+
end
|
|
11
|
+
end
|
data/bin/rails
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
|
3
|
+
|
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/proactive_support/engine', __FILE__)
|
|
6
|
+
|
|
7
|
+
# Set up gems listed in the Gemfile.
|
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
|
9
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
|
10
|
+
|
|
11
|
+
require 'rails/all'
|
|
12
|
+
require 'rails/engine/commands'
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class CreateProactiveSupportNotes < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :proactive_support_notes, options: 'CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' do |t|
|
|
4
|
+
t.integer :customer_id, null: false
|
|
5
|
+
t.integer :user_id, limit: 8, index: true, foreign_key: { references: [:users, :id], on_delete: :set_null}
|
|
6
|
+
t.string :title, null: false
|
|
7
|
+
t.string :content, limit: 16777215
|
|
8
|
+
t.integer :level, default: 0
|
|
9
|
+
t.string :tags
|
|
10
|
+
t.boolean :is_active, default: true
|
|
11
|
+
|
|
12
|
+
t.timestamps null: false
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class CreateProactiveSupportFlags < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :proactive_support_flags, options: 'CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' do |t|
|
|
4
|
+
t.integer :customer_id, null: false
|
|
5
|
+
|
|
6
|
+
t.string :digest, null: false
|
|
7
|
+
t.string :source, null: false
|
|
8
|
+
t.string :identifier, null: false
|
|
9
|
+
t.string :message, null: false
|
|
10
|
+
t.text :filter
|
|
11
|
+
|
|
12
|
+
t.text :debug_params
|
|
13
|
+
t.integer :level, default: 0
|
|
14
|
+
t.string :tags
|
|
15
|
+
t.datetime :last_triggered_at
|
|
16
|
+
t.boolean :is_active, default: true
|
|
17
|
+
t.boolean :is_transient, default: true
|
|
18
|
+
|
|
19
|
+
t.timestamps null: false
|
|
20
|
+
|
|
21
|
+
t.index [:customer_id, :digest], unique: true
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require_dependency "proactive_support/application_controller"
|
|
2
|
+
|
|
3
|
+
module ProactiveSupport
|
|
4
|
+
class NotesController < ApplicationController
|
|
5
|
+
before_action :set_note, only: [:show, :edit, :update, :destroy]
|
|
6
|
+
|
|
7
|
+
# GET /notes
|
|
8
|
+
def index
|
|
9
|
+
@notes = Note.all
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# GET /notes/1
|
|
13
|
+
def show
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# GET /notes/new
|
|
17
|
+
def new
|
|
18
|
+
@note = Note.new
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# GET /notes/1/edit
|
|
22
|
+
def edit
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# POST /notes
|
|
26
|
+
def create
|
|
27
|
+
@note = Note.new(note_params)
|
|
28
|
+
|
|
29
|
+
if @note.save
|
|
30
|
+
redirect_to @note, notice: 'Note was successfully created.'
|
|
31
|
+
else
|
|
32
|
+
render :new
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# PATCH/PUT /notes/1
|
|
37
|
+
def update
|
|
38
|
+
if @note.update(note_params)
|
|
39
|
+
redirect_to @note, notice: 'Note was successfully updated.'
|
|
40
|
+
else
|
|
41
|
+
render :edit
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# DELETE /notes/1
|
|
46
|
+
def destroy
|
|
47
|
+
@note.destroy
|
|
48
|
+
redirect_to notes_url, notice: 'Note was successfully destroyed.'
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
53
|
+
def set_note
|
|
54
|
+
@note = Note.find(params[:id])
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Only allow a trusted parameter "white list" through.
|
|
58
|
+
def note_params
|
|
59
|
+
params.require(:note).permit(:user_id, :message, :level, :tags, :is_active)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>ProactiveSupport</title>
|
|
5
|
+
<%= stylesheet_link_tag "proactive_support/application", media: "all" %>
|
|
6
|
+
<%= javascript_include_tag "proactive_support/application" %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<%= yield %>
|
|
12
|
+
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<%= form_for(@note) do |f| %>
|
|
2
|
+
<% if @note.errors.any? %>
|
|
3
|
+
<div id="error_explanation">
|
|
4
|
+
<h2><%= pluralize(@note.errors.count, "error") %> prohibited this note from being saved:</h2>
|
|
5
|
+
|
|
6
|
+
<ul>
|
|
7
|
+
<% @note.errors.full_messages.each do |message| %>
|
|
8
|
+
<li><%= message %></li>
|
|
9
|
+
<% end %>
|
|
10
|
+
</ul>
|
|
11
|
+
</div>
|
|
12
|
+
<% end %>
|
|
13
|
+
|
|
14
|
+
<div class="field">
|
|
15
|
+
<%= f.label :user_id %><br>
|
|
16
|
+
<%= f.number_field :user_id %>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="field">
|
|
19
|
+
<%= f.label :message %><br>
|
|
20
|
+
<%= f.text_field :message %>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="field">
|
|
23
|
+
<%= f.label :level %><br>
|
|
24
|
+
<%= f.number_field :level %>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="field">
|
|
27
|
+
<%= f.label :tags %><br>
|
|
28
|
+
<%= f.text_area :tags %>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="field">
|
|
31
|
+
<%= f.label :is_active %><br>
|
|
32
|
+
<%= f.check_box :is_active %>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="actions">
|
|
35
|
+
<%= f.submit %>
|
|
36
|
+
</div>
|
|
37
|
+
<% end %>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
|
2
|
+
|
|
3
|
+
<h1>Listing Notes</h1>
|
|
4
|
+
|
|
5
|
+
<table>
|
|
6
|
+
<thead>
|
|
7
|
+
<tr>
|
|
8
|
+
<th>User</th>
|
|
9
|
+
<th>Message</th>
|
|
10
|
+
<th>Level</th>
|
|
11
|
+
<th>Tags</th>
|
|
12
|
+
<th>Is active</th>
|
|
13
|
+
<th colspan="3"></th>
|
|
14
|
+
</tr>
|
|
15
|
+
</thead>
|
|
16
|
+
|
|
17
|
+
<tbody>
|
|
18
|
+
<% @notes.each do |note| %>
|
|
19
|
+
<tr>
|
|
20
|
+
<td><%= note.user_id %></td>
|
|
21
|
+
<td><%= note.message %></td>
|
|
22
|
+
<td><%= note.level %></td>
|
|
23
|
+
<td><%= note.tags %></td>
|
|
24
|
+
<td><%= note.is_active %></td>
|
|
25
|
+
<td><%= link_to 'Show', note %></td>
|
|
26
|
+
<td><%= link_to 'Edit', edit_note_path(note) %></td>
|
|
27
|
+
<td><%= link_to 'Destroy', note, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
|
28
|
+
</tr>
|
|
29
|
+
<% end %>
|
|
30
|
+
</tbody>
|
|
31
|
+
</table>
|
|
32
|
+
|
|
33
|
+
<br>
|
|
34
|
+
|
|
35
|
+
<%= link_to 'New Note', new_note_path %>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
|
2
|
+
|
|
3
|
+
<p>
|
|
4
|
+
<strong>User:</strong>
|
|
5
|
+
<%= @note.user_id %>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p>
|
|
9
|
+
<strong>Message:</strong>
|
|
10
|
+
<%= @note.message %>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p>
|
|
14
|
+
<strong>Level:</strong>
|
|
15
|
+
<%= @note.level %>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
<p>
|
|
19
|
+
<strong>Tags:</strong>
|
|
20
|
+
<%= @note.tags %>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<p>
|
|
24
|
+
<strong>Is active:</strong>
|
|
25
|
+
<%= @note.is_active %>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
<%= link_to 'Edit', edit_note_path(@note) %> |
|
|
29
|
+
<%= link_to 'Back', notes_path %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'proactive_support'
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module ProactiveSupport
|
|
2
|
+
module Mgmt
|
|
3
|
+
class Flags
|
|
4
|
+
class << self
|
|
5
|
+
def set(customer_id, source, identifier, filter, message, options = {})
|
|
6
|
+
digest = to_digest source, identifier, filter
|
|
7
|
+
|
|
8
|
+
::ProactiveSupport::Flag.find_or_initialize_by_customer_id_and_digest(customer_id, digest).tap do |f|
|
|
9
|
+
f.source = source
|
|
10
|
+
f.identifier = identifier
|
|
11
|
+
f.filter = HashWithIndifferentAccess.new filter
|
|
12
|
+
f.message = message
|
|
13
|
+
f.level = options[:level] || ::ProactiveSupport::INFO
|
|
14
|
+
f.debug_params = HashWithIndifferentAccess.new options[:debug_params]
|
|
15
|
+
f.tags = options[:tags]
|
|
16
|
+
f.is_transient = options.fetch(:transient, true) ? true : false
|
|
17
|
+
f.last_triggered_at = ::Time.now
|
|
18
|
+
f.is_active = true
|
|
19
|
+
f.save!
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def clear(customer_id, source, identifier, filter)
|
|
24
|
+
clear_matching customer_id, {digest: to_digest(source, identifier, filter)}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def clear_identifier(customer_id, source, identifier)
|
|
28
|
+
clear_matching customer_id, {source: source, identifier: identifier}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def clear_source(customer_id, source)
|
|
32
|
+
clear_matching customer_id, {source: source}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def to_digest(source, identifier, filter)
|
|
38
|
+
x = "#{source}:#{identifier}:#{filter}"
|
|
39
|
+
::Digest::SHA1.base64digest x
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def clear_matching(customer_id, conditions)
|
|
43
|
+
::ProactiveSupport::Flag.where(customer_id: customer_id, is_active: true).update_all({is_active: false}, conditions)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module ProactiveSupport
|
|
2
|
+
module Mgmt
|
|
3
|
+
class Notes
|
|
4
|
+
class << self
|
|
5
|
+
def create(customer_id, user_id, title, options = {})
|
|
6
|
+
::ProactiveSupport::Note.new.tap do |n|
|
|
7
|
+
n.customer_id = customer_id
|
|
8
|
+
n.user_id = user_id
|
|
9
|
+
n.title = title
|
|
10
|
+
n.content = options[:content]
|
|
11
|
+
n.level = options[:level] || ::ProactiveSupport::INFO
|
|
12
|
+
n.tags = options[:tags]
|
|
13
|
+
n.is_active = true
|
|
14
|
+
n.save!
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# No great way to have a non-rails gem and also a rails engine...
|
|
2
|
+
if defined?(Rails) && Rails.respond_to?(:version) && Rails.respond_to?(:root)
|
|
3
|
+
require 'proactive_support/engine'
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
module ProactiveSupport
|
|
7
|
+
|
|
8
|
+
INFO = 0
|
|
9
|
+
WARNING = 1
|
|
10
|
+
ERROR = 2
|
|
11
|
+
|
|
12
|
+
autoload :Note, ::File.expand_path('../../app/models/proactive_support/note.rb', __FILE__)
|
|
13
|
+
autoload :Flag, ::File.expand_path('../../app/models/proactive_support/flag.rb', __FILE__)
|
|
14
|
+
|
|
15
|
+
class Configuration
|
|
16
|
+
attr_accessor :transient_expiration
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class << self
|
|
20
|
+
attr_writer :configuration
|
|
21
|
+
|
|
22
|
+
def level_to_bootstrap(level)
|
|
23
|
+
case level
|
|
24
|
+
when INFO then 'info'
|
|
25
|
+
when WARNING then 'warning'
|
|
26
|
+
when ERROR then 'danger'
|
|
27
|
+
else ''
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
module_function
|
|
33
|
+
def configuration
|
|
34
|
+
@configuration ||= Configuration.new.tap do |c|
|
|
35
|
+
c.transient_expiration = 1.day
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def configure
|
|
40
|
+
yield(configuration)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
require 'proactive_support/mgmt/flags'
|
|
45
|
+
require 'proactive_support/mgmt/notes'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
namespace :proactive_support do
|
|
2
|
+
desc 'Set a flag'
|
|
3
|
+
task :set, [:customer_id, :source, :identifier, :message] do |_, args|
|
|
4
|
+
Customer.using_data_shard_for(args[:customer_id]) do
|
|
5
|
+
::ProactiveSupport::Mgmt::Flags.set args[:customer_id], args[:source], args[:identifier], {}, args[:message]
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
desc 'Clear all flags'
|
|
10
|
+
task :clear do
|
|
11
|
+
::Multidb.run_on_all_shards do
|
|
12
|
+
::ProactiveSupport::Flag.update_all({is_active: false}, {is_active: true})
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
|
2
|
+
require 'proactive_support/version'
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |s|
|
|
5
|
+
s.name = 'proactive_support'
|
|
6
|
+
s.version = ProactiveSupport::VERSION
|
|
7
|
+
s.date = '2016-05-03'
|
|
8
|
+
s.authors = ['Steve Frank']
|
|
9
|
+
s.email = %w(steve@cloudhealthtech.com)
|
|
10
|
+
s.homepage = 'https://github.com/CloudHealth/proactive_support/wiki'
|
|
11
|
+
s.summary = 'Proactive Support module.'
|
|
12
|
+
s.description = 'Proactive Support module.'
|
|
13
|
+
s.license = 'MIT'
|
|
14
|
+
|
|
15
|
+
s.files = `git ls-files`.split("\n")
|
|
16
|
+
|
|
17
|
+
s.require_paths = %w(lib)
|
|
18
|
+
|
|
19
|
+
s.add_dependency 'activerecord', '>= 3'
|
|
20
|
+
|
|
21
|
+
s.add_development_dependency 'sqlite3'
|
|
22
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
|
File without changes
|