Class: SolidLog::UI::FieldsController

Inherits:
BaseController show all
Defined in:
app/controllers/solid_log/ui/fields_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#authenticate_user!

Instance Method Details

#demote ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'app/controllers/solid_log/ui/fields_controller.rb', line 23

def demote
  @field = Field.find(params[:id])

  SolidLog.without_logging do
    @field.demote!
  end

  redirect_to fields_path, notice: "Field '#{@field.name}' marked as unpromoted"
end

#destroy ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/solid_log/ui/fields_controller.rb', line 45

def destroy
  @field = Field.find(params[:id])
  field_name = @field.name

  SolidLog.without_logging do
    @field.destroy
  end

  redirect_to fields_path, notice: "Field '#{field_name}' removed from registry"
end

#index ⇒ Object



4
5
6
7
8
9
10
11
# File 'app/controllers/solid_log/ui/fields_controller.rb', line 4

def index
  @fields = SolidLog.without_logging do
    Field.order(usage_count: :desc)
  end

  @hot_fields = @fields.select { |f| f.usage_count >= 1000 }
  @total_fields = @fields.size
end

#promote ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'app/controllers/solid_log/ui/fields_controller.rb', line 13

def promote
  @field = Field.find(params[:id])

  SolidLog.without_logging do
    @field.promote!
  end

  redirect_to fields_path, notice: "Field '#{@field.name}' marked as promoted"
end

#update_filter_type ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/solid_log/ui/fields_controller.rb', line 33

def update_filter_type
  @field = Field.find(params[:id])

  SolidLog.without_logging do
    if @field.update(filter_type: params[:field][:filter_type])
      redirect_to fields_path, notice: "Filter type for '#{@field.name}' updated to #{@field.filter_type}"
    else
      redirect_to fields_path, alert: "Failed to update filter type: #{@field.errors.full_messages.join(', ')}"
    end
  end
end