Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 01:10:28 +01:00
Add discourse_plugin_statistics plugin definition
Dieser Commit ist enthalten in:
Ursprung
43007d8130
Commit
21d0357ffd
5 geänderte Dateien mit 182 neuen und 1 gelöschten Zeilen
|
@ -6,3 +6,6 @@ RSpec/ContextWording:
|
|||
|
||||
RSpec/DescribeClass:
|
||||
Enabled: false
|
||||
|
||||
Discourse/TimeEqMatcher:
|
||||
Enabled: false
|
||||
|
|
|
@ -157,7 +157,7 @@ class CustomWizard::Subscription
|
|||
return :none unless subscribed?
|
||||
return :business if business?
|
||||
return :standard if standard?
|
||||
return :community if community?
|
||||
:community if community?
|
||||
end
|
||||
|
||||
def subscribed?
|
||||
|
|
94
lib/discourse_plugin_statistics/plugin.rb
Normale Datei
94
lib/discourse_plugin_statistics/plugin.rb
Normale Datei
|
@ -0,0 +1,94 @@
|
|||
# frozen_string_literal: true
|
||||
module DiscoursePluginStatistics
|
||||
class Plugin
|
||||
def self.discourse_custom_wizard
|
||||
subscription_features = {
|
||||
wizard: {
|
||||
save_submissions: 0,
|
||||
after_signup: 0,
|
||||
prompt_completion: 0,
|
||||
required: 0,
|
||||
permitted: 0,
|
||||
},
|
||||
step: {
|
||||
required_data: 0,
|
||||
permitted_params: 0,
|
||||
force_final: 0
|
||||
},
|
||||
field: {
|
||||
condition: 0,
|
||||
type: {
|
||||
text: 0,
|
||||
textarea: 0,
|
||||
text_only: 0,
|
||||
date: 0,
|
||||
time: 0,
|
||||
date_time: 0,
|
||||
number: 0,
|
||||
checkbox: 0,
|
||||
dropdown: 0,
|
||||
composer: 0,
|
||||
composer_preview: 0,
|
||||
url: 0,
|
||||
upload: 0,
|
||||
tag: 0,
|
||||
category: 0,
|
||||
group: 0,
|
||||
user_selector: 0,
|
||||
},
|
||||
realtime_validations: 0
|
||||
},
|
||||
action: {
|
||||
type: {
|
||||
create_topic: 0,
|
||||
send_message: 0,
|
||||
update_profile: 0,
|
||||
open_composer: 0,
|
||||
route_to: 0,
|
||||
send_to_api: 0,
|
||||
watch_categories: 0,
|
||||
watch_tags: 0,
|
||||
add_to_group: 0,
|
||||
create_group: 0,
|
||||
create_category: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
increment_feature_count = lambda do |type, key, value|
|
||||
if key == 'type'
|
||||
subscription_features[type.to_sym][:type][value.to_sym] += 1
|
||||
elsif !subscription_features[type.to_sym][key.to_sym].nil?
|
||||
subscription_features[type.to_sym][key.to_sym] += 1
|
||||
end
|
||||
end
|
||||
|
||||
CustomWizard::Template.list.each do |template|
|
||||
template.each do |key, value|
|
||||
increment_feature_count.call(:wizard, key, value)
|
||||
end
|
||||
template['steps'].each do |step|
|
||||
step.each do |key, value|
|
||||
increment_feature_count.call(:step, key, value)
|
||||
end
|
||||
step['fields'].each do |field|
|
||||
field.each do |key, value|
|
||||
increment_feature_count.call(:field, key, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
template['actions'].each do |action|
|
||||
action.each do |key, value|
|
||||
increment_feature_count.call(:action, key, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
{
|
||||
total_wizards: CustomWizard::Template.list.size,
|
||||
subscription_type: CustomWizard::Subscription.type.to_s,
|
||||
subscription_features: subscription_features
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8,6 +8,7 @@
|
|||
# subscription_url: https://coop.pavilion.tech
|
||||
|
||||
gem 'liquid', '5.0.1', require: true
|
||||
gem 'discourse_plugin_statistics', '0.1.0.pre1', require: true
|
||||
register_asset 'stylesheets/common/admin.scss'
|
||||
register_asset 'stylesheets/common/wizard.scss'
|
||||
|
||||
|
@ -73,6 +74,7 @@ after_initialize do
|
|||
../lib/custom_wizard/api/log_entry.rb
|
||||
../lib/custom_wizard/liquid_extensions/first_non_empty.rb
|
||||
../lib/custom_wizard/exceptions/exceptions.rb
|
||||
../lib/discourse_plugin_statistics/plugin.rb
|
||||
../app/serializers/custom_wizard/api/authorization_serializer.rb
|
||||
../app/serializers/custom_wizard/api/basic_endpoint_serializer.rb
|
||||
../app/serializers/custom_wizard/api/endpoint_serializer.rb
|
||||
|
|
82
spec/components/discourse_plugin_statistics/plugin_spec.rb
Normale Datei
82
spec/components/discourse_plugin_statistics/plugin_spec.rb
Normale Datei
|
@ -0,0 +1,82 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
describe DiscoursePluginStatistics::Plugin do
|
||||
let(:template_json) { get_wizard_fixture("wizard") }
|
||||
|
||||
describe "#discourse_custom_wizard" do
|
||||
before do
|
||||
enable_subscription('standard')
|
||||
|
||||
CustomWizard::Template.save(template_json, skip_jobs: true)
|
||||
|
||||
template_json_2 = template_json.dup
|
||||
template_json_2["id"] = 'super_mega_fun_wizard_2'
|
||||
CustomWizard::Template.save(template_json_2, skip_jobs: true)
|
||||
|
||||
@data = DiscoursePluginStatistics::Plugin.discourse_custom_wizard
|
||||
end
|
||||
|
||||
it "includes a total wizard count" do
|
||||
expect(@data[:total_wizards]).to eq(2)
|
||||
end
|
||||
|
||||
it "includes the subscription type" do
|
||||
expect(@data[:subscription_type]).to eq('standard')
|
||||
end
|
||||
|
||||
it "includes a count of features being used across all wizards" do
|
||||
expect(@data[:subscription_features]).to eq(
|
||||
wizard: {
|
||||
save_submissions: 2,
|
||||
after_signup: 2,
|
||||
prompt_completion: 2,
|
||||
required: 0,
|
||||
permitted: 0,
|
||||
},
|
||||
step: {
|
||||
required_data: 0,
|
||||
permitted_params: 0,
|
||||
force_final: 0
|
||||
},
|
||||
field: {
|
||||
condition: 0,
|
||||
type: {
|
||||
text: 2,
|
||||
textarea: 2,
|
||||
text_only: 2,
|
||||
date: 2,
|
||||
time: 2,
|
||||
date_time: 2,
|
||||
number: 2,
|
||||
checkbox: 2,
|
||||
dropdown: 2,
|
||||
composer: 0,
|
||||
composer_preview: 0,
|
||||
url: 0,
|
||||
upload: 0,
|
||||
tag: 0,
|
||||
category: 0,
|
||||
group: 0,
|
||||
user_selector: 0,
|
||||
},
|
||||
realtime_validations: 0
|
||||
},
|
||||
action: {
|
||||
type: {
|
||||
create_topic: 2,
|
||||
send_message: 0,
|
||||
update_profile: 2,
|
||||
open_composer: 2,
|
||||
route_to: 2,
|
||||
send_to_api: 0,
|
||||
watch_categories: 0,
|
||||
watch_tags: 0,
|
||||
add_to_group: 0,
|
||||
create_group: 0,
|
||||
create_category: 0,
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
Laden …
In neuem Issue referenzieren