telegram_bot_engine 0.3.2 → 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: b435eb056de0e35576e718a7b28785871c14a0ac0cb56fb56d865e8422b956f8
4
- data.tar.gz: 0ba258e22ae682324f4808786f60dd8d9d1239d07e650b507683dbba58cbfece
3
+ metadata.gz: 14f170bf1a00f88a7a92e5f5a5715903855c3b84370d5aee33356ee6596494f7
4
+ data.tar.gz: e853b4600c0a4961283fad2f1c01bc71e9b488411e0a51a998504cfb3b1dd479
5
5
  SHA512:
6
- metadata.gz: 1d9b49c4b5d4a5c41568a22325cdbd6f7139812f3d51506375153994a1b5db761c987c0770363c0ce5d06e1dd132544b6ce64ba46ae744c309b890cdcb10c9b0
7
- data.tar.gz: 71274793c8366f7fda154c07d93d1b61f4a8df7246034f6a8a629433f7eb77194fc85efe9fc35a492f901577e8391c2141a0f2490e3acf8782444e18817b9516
6
+ metadata.gz: d9c5d4a8be4625cfdfe64b9b874aea384e71811f1561122e5a3c0bfbf9dfba4c22d8fea604d3e98dde9f9fadff4939c36d8ffe4ebb1a9e869a48e279f001b21b
7
+ data.tar.gz: 53df73d3e4df5db59527a3604bad4be9fb601febc20ec507174ff5e795b0f2ca6595f37e3d15128b6fc3dfcc2b126afb55a08d03080fb6e5e30042fbf8262f53
@@ -7,11 +7,16 @@ module TelegramBotEngine
7
7
 
8
8
  def index
9
9
  unless Event.table_exists?
10
- @events = []
11
- @total_count = 0
12
- @page = 1
13
- @total_pages = 0
14
- flash.now[:alert] = "Events table not found. Run: rails telegram_bot_engine:install:migrations && rails db:migrate"
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
15
20
  return
16
21
  end
17
22
 
@@ -24,6 +29,31 @@ module TelegramBotEngine
24
29
  @page = [params[:page].to_i, 1].max
25
30
  @events = @events.offset((@page - 1) * PER_PAGE).limit(PER_PAGE)
26
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
27
57
  end
28
58
  end
29
59
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TelegramBotEngine
4
- VERSION = "0.3.2"
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.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TelegramBotEngine Contributors