telegram_bot_engine 0.3.1 → 0.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2931a21db63313dfcf3ebabe3e8de59eeb4802cabdcf48d0223c21994afa7dae
4
- data.tar.gz: 15875cef95bb34506dd20b9364dc575507c5e4085686eae664fe68defff6d589
3
+ metadata.gz: 14f170bf1a00f88a7a92e5f5a5715903855c3b84370d5aee33356ee6596494f7
4
+ data.tar.gz: e853b4600c0a4961283fad2f1c01bc71e9b488411e0a51a998504cfb3b1dd479
5
5
  SHA512:
6
- metadata.gz: ea050ef5a7a67a1931d41a66bb38e6cf9485d4bbb54e6a39c937c5856a7d2c8e38be42a7c9af1e69418d875288bcb0273b092dcb036637117df912d66db382ec
7
- data.tar.gz: 7f1c49f8b38a242a109fe06a75048db2a3e66a3246f88944b228322ac33bb79c6a5c93855c5a193e835e53df72bdbbe5a2795c368a98798ca7571ca37e13e06c
6
+ metadata.gz: d9c5d4a8be4625cfdfe64b9b874aea384e71811f1561122e5a3c0bfbf9dfba4c22d8fea604d3e98dde9f9fadff4939c36d8ffe4ebb1a9e869a48e279f001b21b
7
+ data.tar.gz: 53df73d3e4df5db59527a3604bad4be9fb601febc20ec507174ff5e795b0f2ca6595f37e3d15128b6fc3dfcc2b126afb55a08d03080fb6e5e30042fbf8262f53
@@ -4,6 +4,7 @@ module TelegramBotEngine
4
4
  module Admin
5
5
  class BaseController < ActionController::Base
6
6
  layout "telegram_bot_engine/admin/layouts/application"
7
+
7
8
  before_action :check_admin_enabled!
8
9
 
9
10
  private
@@ -6,6 +6,20 @@ module TelegramBotEngine
6
6
  PER_PAGE = 50
7
7
 
8
8
  def index
9
+ unless Event.table_exists?
10
+ respond_to do |format|
11
+ format.html do
12
+ @events = []
13
+ @total_count = 0
14
+ @page = 1
15
+ @total_pages = 0
16
+ flash.now[:alert] = "Events table not found. Run: rails telegram_bot_engine:install:migrations && rails db:migrate"
17
+ end
18
+ format.json { render json: { error: "Events table not found" }, status: :service_unavailable }
19
+ end
20
+ return
21
+ end
22
+
9
23
  @events = Event.recent
10
24
  @events = @events.by_type(params[:type]) if params[:type].present?
11
25
  @events = @events.by_action(params[:action_name]) if params[:action_name].present?
@@ -15,6 +29,31 @@ module TelegramBotEngine
15
29
  @page = [params[:page].to_i, 1].max
16
30
  @events = @events.offset((@page - 1) * PER_PAGE).limit(PER_PAGE)
17
31
  @total_pages = (@total_count.to_f / PER_PAGE).ceil
32
+
33
+ respond_to do |format|
34
+ format.html
35
+ format.json do
36
+ render json: {
37
+ events: @events.map { |e|
38
+ {
39
+ id: e.id,
40
+ event_type: e.event_type,
41
+ action: e.action,
42
+ chat_id: e.chat_id,
43
+ username: e.username,
44
+ details: e.details,
45
+ created_at: e.created_at.iso8601
46
+ }
47
+ },
48
+ meta: {
49
+ total_count: @total_count,
50
+ page: @page,
51
+ total_pages: @total_pages,
52
+ per_page: PER_PAGE
53
+ }
54
+ }
55
+ end
56
+ end
18
57
  end
19
58
  end
20
59
  end
@@ -15,6 +15,7 @@ module TelegramBotEngine
15
15
 
16
16
  def self.log(event_type:, action:, chat_id: nil, username: nil, details: {})
17
17
  return unless TelegramBotEngine.config.event_logging
18
+ return unless table_exists?
18
19
 
19
20
  create!(
20
21
  event_type: event_type,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TelegramBotEngine
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telegram_bot_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TelegramBotEngine Contributors