Skip to content

Commit

Permalink
feat(crawler): add possibility of indexing private articles
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerska committed Sep 12, 2017
1 parent f94c5a2 commit 950444e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions crawler/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
}.merge(JSON.parse(ENV['CONFIG']))

CONFIG['access_policies'] ||= ['everybody']
CONFIG['private'] ||= false
3 changes: 2 additions & 1 deletion crawler/types/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def translation t
super(t).merge(selected).merge(
category: simple_category,
section: simple_section.merge(
full_path: "#{simple_category[:title]} > #{simple_section[:title]}"
full_path: "#{simple_category[:title]} > #{simple_section[:title]}",
access_policy: section.access_policy(complete: CONFIG['private'])
),
label_names: tags(t.locale),
created_at_iso: @zendesk_obj.created_at.utc.iso8601,
Expand Down
14 changes: 9 additions & 5 deletions crawler/types/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ def ignore? t
super(t) ||
!category.exists?(t.locale) ||
category.ignore?(t) ||
!CONFIG['access_policies'].include?(access_policy)
(
!CONFIG['private'] &&
!CONFIG['access_policies'].include?(access_policy)
)
end

protected

def access_policy
@zendesk_obj.access_policy['access_policy']['viewable_by']
def access_policy complete: false
res = @zendesk_obj.access_policy['access_policy']
complete ? res : res['viewable_by']
end

protected

def translation t
super(t).merge(
category: category.simple(t),
Expand Down

0 comments on commit 950444e

Please sign in to comment.