Class: VideoSeoCheckService
- Inherits:
-
Object
- Object
- VideoSeoCheckService
- Defined in:
- app/services/video_seo_check_service.rb
Constant Summary collapse
- SEO_TITLE_MIN_LENGTH =
SEO constants - fallback if not loaded from initializer
50- SEO_TITLE_MAX_LENGTH =
65- TITLE_MAX_LENGTH =
150- SEO_META_DESCRIPTION_MIN_LENGTH =
120- SEO_META_DESCRIPTION_MAX_LENGTH =
155- SEO_SUB_HEADER_MIN_LENGTH =
50- SEO_SUB_HEADER_MAX_LENGTH =
70
Instance Method Summary collapse
-
#analyze_seo_health ⇒ Object
Returns a hash of all SEO health check results.
-
#detailed_analysis ⇒ Object
Returns detailed analysis with character counts and recommendations.
-
#expanded_description_quality_status ⇒ Object
Returns individual status for expanded description.
-
#initialize(video) ⇒ VideoSeoCheckService
constructor
A new instance of VideoSeoCheckService.
-
#meta_description_quality_status ⇒ Object
Returns individual status for meta description.
-
#meta_title_quality_status ⇒ Object
Returns individual status for meta title.
-
#sub_header_quality_status ⇒ Object
Returns individual status for sub header.
Constructor Details
#initialize(video) ⇒ VideoSeoCheckService
Returns a new instance of VideoSeoCheckService.
11 12 13 |
# File 'app/services/video_seo_check_service.rb', line 11 def initialize(video) @video = video end |
Instance Method Details
#analyze_seo_health ⇒ Object
Returns a hash of all SEO health check results
16 17 18 19 20 21 22 23 |
# File 'app/services/video_seo_check_service.rb', line 16 def analyze_seo_health { meta_title: , meta_description: , sub_header: sub_header_quality_status, expanded_description: } end |
#detailed_analysis ⇒ Object
Returns detailed analysis with character counts and recommendations
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/services/video_seo_check_service.rb', line 58 def detailed_analysis { meta_title: { status: , current_length: @video.&.length || 0, min_length: SEO_TITLE_MIN_LENGTH, max_length: SEO_TITLE_MAX_LENGTH, recommendation: }, meta_description: { status: , current_length: @video.&.length || 0, min_length: SEO_META_DESCRIPTION_MIN_LENGTH, max_length: SEO_META_DESCRIPTION_MAX_LENGTH, recommendation: }, sub_header: { status: sub_header_quality_status, current_length: @video.sub_header&.length || 0, min_length: SEO_SUB_HEADER_MIN_LENGTH, max_length: SEO_SUB_HEADER_MAX_LENGTH, recommendation: sub_header_recommendation }, expanded_description: { status: , current_length: @video.&.length || 0, min_length: 200, max_length: 1000, recommendation: } } end |
#expanded_description_quality_status ⇒ Object
Returns individual status for expanded description
50 51 52 53 54 55 |
# File 'app/services/video_seo_check_service.rb', line 50 def return 'missing' unless @video..present? return 'poor' if @video..length < 200 || @video..length > 1000 'good' end |
#meta_description_quality_status ⇒ Object
Returns individual status for meta description
34 35 36 37 38 39 |
# File 'app/services/video_seo_check_service.rb', line 34 def return 'missing' unless @video..present? return 'poor' if @video..length < SEO_META_DESCRIPTION_MIN_LENGTH || @video..length > SEO_META_DESCRIPTION_MAX_LENGTH 'good' end |
#meta_title_quality_status ⇒ Object
Returns individual status for meta title
26 27 28 29 30 31 |
# File 'app/services/video_seo_check_service.rb', line 26 def return 'missing' unless @video..present? return 'poor' if @video..length < SEO_TITLE_MIN_LENGTH || @video..length > SEO_TITLE_MAX_LENGTH 'good' end |
#sub_header_quality_status ⇒ Object
Returns individual status for sub header
42 43 44 45 46 47 |
# File 'app/services/video_seo_check_service.rb', line 42 def sub_header_quality_status return 'missing' unless @video.sub_header.present? return 'poor' if @video.sub_header.length < SEO_SUB_HEADER_MIN_LENGTH || @video.sub_header.length > SEO_SUB_HEADER_MAX_LENGTH 'good' end |