ad_space 0.1.6 → 0.1.8
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -2
- data/app/controllers/ad_space/api/v1/advertisements_controller.rb +1 -2
- data/app/models/ad_space/advertisement.rb +16 -2
- data/app/models/ad_space/slot.rb +4 -2
- data/app/serializers/v1/advertisement_serializer.rb +8 -7
- data/app/validators/url_or_custom_scheme_validator.rb +4 -1
- data/lib/ad_space/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c294841e4e377ecf99cc3aa8f3f42ac3a9800eb88ee17ae37351ba9087b8f8b
|
4
|
+
data.tar.gz: 435767755057233d635c962149960a1b7f6b87dfa30bc2cc31743309b4a64686
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c9737924bd24df44e888663f41c7651d009a1860d77754ae943cffdb9e93e630dba0458207d44759f20a1b666a3a45298f715e53897c44d13ec2c40c04edae9
|
7
|
+
data.tar.gz: f79ae7773402d55979462e9dfab97481b2a8bd3a645bd22c964c79e65751d37d6a620fe19d2fc51dcf9f6091468cd4bbc0b0573e33d9ca12e423b5873e25e7fe
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -91,8 +91,6 @@ mount AdSpace::Engine => "/ad_space"
|
|
91
91
|
## TODO
|
92
92
|
- 预览广告功能,支持参数可以直接在手机端拉取自定广告,展示在特定的位置
|
93
93
|
- 效果指标统计功能,ai 方案,计算成本
|
94
|
-
- slot 编码 弄小一点,uuid 都弄小点
|
95
|
-
- uuid 改为 trace_id 追踪码?
|
96
94
|
- 各个指标如何统计
|
97
95
|
- 异步任务规则,打点,异步通过阿里云日志写回,sidekiq 测试
|
98
96
|
- tacker id 跟阿里云 获取统计 异步结算
|
@@ -106,3 +104,9 @@ mount AdSpace::Engine => "/ad_space"
|
|
106
104
|
- 操作 调整UI
|
107
105
|
- toast 消息
|
108
106
|
- tailwindcss
|
107
|
+
- 平台 标题 开始时间 结束时间 位置 广告类型 可见性 目标版本
|
108
|
+
|
109
|
+
```
|
110
|
+
ip, datetime ad_id, impressions, device_id ,platform, version_code, version_name, channel, user_id
|
111
|
+
ip, datetime ad_id, clicks, device_id, platform, version_code, version_name, channel, user_id
|
112
|
+
```
|
@@ -4,8 +4,7 @@ class AdSpace::Api::V1::AdvertisementsController < ActionController::API
|
|
4
4
|
def index
|
5
5
|
builder = AdSpace::Advertisement.includes(:slot).where(platform: params[:platform])
|
6
6
|
builder = builder.published.unexpired
|
7
|
-
builder = builder.where(
|
8
|
-
|
7
|
+
builder = builder.joins(:slot).where("ad_space_slots.uuid": params[:slot_ids].split(",")) unless params[:slot_ids].blank?
|
9
8
|
# TODO: 动态可配置,不同项目可以自定义特殊的查询条件,基于builder
|
10
9
|
# 0. 判断是否有配置动态用户信息,proc
|
11
10
|
# 1. 通过token获取用户信息 proc
|
@@ -38,8 +38,20 @@ module AdSpace
|
|
38
38
|
archived_at.present?
|
39
39
|
end
|
40
40
|
|
41
|
+
def dsp_ad?
|
42
|
+
ad_type == "dsp"
|
43
|
+
end
|
44
|
+
|
45
|
+
def custom_ad?
|
46
|
+
ad_type == "custom"
|
47
|
+
end
|
48
|
+
|
49
|
+
def trace_id
|
50
|
+
uuid
|
51
|
+
end
|
52
|
+
|
41
53
|
def cover_url(size = nil)
|
42
|
-
if
|
54
|
+
if self.splash?
|
43
55
|
return cover_sm.attached? ? cover_sm.url : nil if size == 'little'
|
44
56
|
return cover_md.attached? ? cover_md.url : nil if size == 'middle'
|
45
57
|
return cover_lg.attached? ? cover_lg.url : nil if size == 'large'
|
@@ -59,7 +71,9 @@ module AdSpace
|
|
59
71
|
def generate_uuid
|
60
72
|
if self.uuid.blank?
|
61
73
|
begin
|
62
|
-
|
74
|
+
characters = ('a'..'z').to_a + ('0'..'9').to_a
|
75
|
+
random_string = Array.new(4) { characters.sample }.join
|
76
|
+
self.uuid = random_string
|
63
77
|
end while self.class.exists?(uuid: uuid)
|
64
78
|
end
|
65
79
|
end
|
data/app/models/ad_space/slot.rb
CHANGED
@@ -19,9 +19,11 @@ module AdSpace
|
|
19
19
|
def generate_uuid
|
20
20
|
if self.uuid.blank?
|
21
21
|
begin
|
22
|
-
|
22
|
+
characters = ('a'..'z').to_a + ('0'..'9').to_a
|
23
|
+
random_string = Array.new(4) { characters.sample }.join
|
24
|
+
self.uuid = random_string
|
23
25
|
end while self.class.exists?(uuid: uuid)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
27
|
-
end
|
29
|
+
end
|
@@ -2,16 +2,16 @@
|
|
2
2
|
|
3
3
|
module V1
|
4
4
|
class AdvertisementSerializer < ActiveModel::Serializer
|
5
|
-
attributes :
|
5
|
+
attributes :trace_id, :started_at, :ended_at, :slot_id, :ad_type, :visibility, :weight
|
6
6
|
|
7
|
-
attribute :scheme_url, if: -> { object.
|
8
|
-
attribute :image_url, if: -> { object.
|
9
|
-
attribute :dsp_type, if: -> { object.
|
7
|
+
attribute :scheme_url, if: -> { object.custom_ad? }
|
8
|
+
attribute :image_url, if: -> { object.custom_ad? }
|
9
|
+
attribute :dsp_type, if: -> { object.dsp_ad? }
|
10
10
|
|
11
11
|
attribute :splash_ui_type, if: -> { object.splash? }
|
12
12
|
attribute :splash_countdown, if: -> { object.splash? }
|
13
13
|
|
14
|
-
def
|
14
|
+
def slot_id
|
15
15
|
object.slot.uuid
|
16
16
|
end
|
17
17
|
|
@@ -20,11 +20,12 @@ module V1
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def ended_at
|
23
|
-
object.
|
23
|
+
object.ended_at.to_i
|
24
24
|
end
|
25
25
|
|
26
26
|
def image_url
|
27
27
|
object.cover_url(instance_options[:size])
|
28
28
|
end
|
29
29
|
end
|
30
|
-
end
|
30
|
+
end
|
31
|
+
|
@@ -15,6 +15,9 @@ class UrlOrCustomSchemeValidator < ActiveModel::EachValidator
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def valid_custom_scheme?(value)
|
18
|
-
|
18
|
+
uri = URI.parse(value)
|
19
|
+
uri.scheme.present? && uri.scheme =~ /\A\w+\z/ && uri.host.present?
|
20
|
+
rescue URI::InvalidURIError
|
21
|
+
false
|
19
22
|
end
|
20
23
|
end
|
data/lib/ad_space/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ad_space
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 42up
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|