Commit 540a25dc by yuzixun

添加创建NotificationStatistic的逻辑

parent d2b2b524
...@@ -7,7 +7,7 @@ ruby '2.6.0' ...@@ -7,7 +7,7 @@ ruby '2.6.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.2', '>= 5.2.2.1' gem 'rails', '~> 5.2.2', '>= 5.2.2.1'
# Use sqlite3 as the database for Active Record # Use sqlite3 as the database for Active Record
gem 'sqlite3' gem 'mysql2', '>= 0.3.18', '< 0.5'
# Use Puma as the app server # Use Puma as the app server
gem 'puma', '~> 3.11' gem 'puma', '~> 3.11'
# Use SCSS for stylesheets # Use SCSS for stylesheets
......
...@@ -133,6 +133,7 @@ GEM ...@@ -133,6 +133,7 @@ GEM
minitest (5.11.3) minitest (5.11.3)
msgpack (1.2.10) msgpack (1.2.10)
multi_xml (0.6.0) multi_xml (0.6.0)
mysql2 (0.4.10)
net-scp (1.2.1) net-scp (1.2.1)
net-ssh (>= 2.6.5) net-ssh (>= 2.6.5)
net-ssh (5.1.0) net-ssh (5.1.0)
...@@ -228,7 +229,6 @@ GEM ...@@ -228,7 +229,6 @@ GEM
actionpack (>= 4.0) actionpack (>= 4.0)
activesupport (>= 4.0) activesupport (>= 4.0)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
sqlite3 (1.4.1)
sshkit (1.18.0) sshkit (1.18.0)
net-scp (>= 1.1.2) net-scp (>= 1.1.2)
net-ssh (>= 2.8.0) net-ssh (>= 2.8.0)
...@@ -272,6 +272,7 @@ DEPENDENCIES ...@@ -272,6 +272,7 @@ DEPENDENCIES
igetui-ruby igetui-ruby
jbuilder (~> 2.5) jbuilder (~> 2.5)
listen (>= 3.0.5, < 3.2) listen (>= 3.0.5, < 3.2)
mysql2 (>= 0.3.18, < 0.5)
puma (~> 3.11) puma (~> 3.11)
rails (~> 5.2.2, >= 5.2.2.1) rails (~> 5.2.2, >= 5.2.2.1)
rails_param (~> 0.10.2) rails_param (~> 0.10.2)
...@@ -282,7 +283,6 @@ DEPENDENCIES ...@@ -282,7 +283,6 @@ DEPENDENCIES
sidekiq (~> 4.1, >= 4.1.2) sidekiq (~> 4.1, >= 4.1.2)
spring spring
spring-watcher-listen (~> 2.0.0) spring-watcher-listen (~> 2.0.0)
sqlite3
turbolinks (~> 5) turbolinks (~> 5)
tzinfo-data tzinfo-data
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
...@@ -292,4 +292,4 @@ RUBY VERSION ...@@ -292,4 +292,4 @@ RUBY VERSION
ruby 2.6.0p0 ruby 2.6.0p0
BUNDLED WITH BUNDLED WITH
1.17.2 1.17.3
...@@ -32,6 +32,9 @@ class PushsController < ApplicationController ...@@ -32,6 +32,9 @@ class PushsController < ApplicationController
device_ids_opts = JSON.parse(params[:device_ids_opts]) rescue {} device_ids_opts = JSON.parse(params[:device_ids_opts]) rescue {}
token = token_and_options(request).first token = token_and_options(request).first
if token == Token.token(params[:app_name]) if token == Token.token(params[:app_name])
# 写入记录
NotificationStatistic.create_by_params(igetui_opts, message, device_ids_opts, params[:app_type])
if params.has_key?(:sync_push) if params.has_key?(:sync_push)
timeout_seconds = $redis.get('push_timeout').to_i timeout_seconds = $redis.get('push_timeout').to_i
if timeout_seconds > 0 if timeout_seconds > 0
......
class NotificationStatistic < ApplicationRecord
# 当前app端传递的platform的值:
# android: igetui, xiaomi, huawei
# iso: igetui 目前还不清楚为啥不用apns,暂时不修改
enum platform: %i[igetui apns xiaomi huawei]
enum device_platform: %i[ios android]
# 用于区分当前的应用,为了推送准备, 因为推送需要根据不同的应用使用不同的 id,secret等。
enum app_type: %i[ik_duli lx_duli lx_yun aike_yun]
def self.create_by_params(igetui_opts, message, device_ids_opts, app_type)
device_ids_opts.each do |platform, client_ids|
client_ids.each do |client_id|
NotificationStatistic.create(
organization_id: igetui_opts[:organization_id],
user_id: igetui_opts[:user_id],
notification_id: message[:id],
client_id: client_id,
platform: platform,
device_platform: igetui_opts[:transmission_type],
app_type: app_type,
ip: igetui_opts[:ip],
)
end
end
rescue => e
Rails.logger.info "exception is #{e}"
e.backtrace.each { |l| Rails.logger.info l }
end
end
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default default: &default
adapter: sqlite3 adapter: mysql2
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> encoding: utf8
timeout: 5000 pool: 3
host: rm-m5ef10gzq1n5e7b9abo.mysql.rds.aliyuncs.com
username: crm_dev
password: 4LwSJlWiM9Krlb8g
development: development:
<<: *default <<: *default
database: db/development.sqlite3 database: crm_dev
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production: production:
<<: *default <<: *default
database: db/production.sqlite3 database: crm_dev
\ No newline at end of file
class CreateNotificationStatistics < ActiveRecord::Migration[5.2]
def change
create_table :notification_statistics do |t|
t.integer :organization_id, comment: "关联公司"
t.integer :user_id, comment: "关联用户" # user id
t.integer :notification_id, comment: "关联通知ID" # id
t.boolean :is_received, comment: "是否收到" # APP 上报
t.string :client_id, comment: "个推ClientID" # 接口调用
t.integer :platform, comment: "推送平台" #
t.integer :device_platform, comment: "系统" # device_platform
t.integer :app_type, comment: "版本" # 调用接口时 app_type
t.string :device_model, comment: "设备型号" # APP 上报
t.string :ip, comment: "IP地址" # 可能拿不到
t.datetime :created_at
t.datetime :updated_at
t.timestamps null: false
end
end
end
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment