mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 11:08:04 +00:00 
			
		
		
		
	fix : Help Center article view count (#6429)
* fix: resolves issue with non updating article view count Co-authored-by: BikashSah999 <51731962+BikashSah999@users.noreply.github.com> * Update articles_controller.rb --------- Co-authored-by: BikashSah999 <51731962+BikashSah999@users.noreply.github.com> Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
		| @@ -55,7 +55,8 @@ class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController | |||||||
|  |  | ||||||
|   def article_params |   def article_params | ||||||
|     params.require(:article).permit( |     params.require(:article).permit( | ||||||
|       :title, :slug, :content, :description, :position, :category_id, :author_id, :associated_article_id, :status, meta: [:title, :description, |       :title, :slug, :content, :description, :position, :category_id, :author_id, :associated_article_id, :status, meta: [:title, | ||||||
|  |                                                                                                                           :description, | ||||||
|                                                                                                                           { tags: [] }] |                                                                                                                           { tags: [] }] | ||||||
|     ) |     ) | ||||||
|   end |   end | ||||||
|   | |||||||
| @@ -16,6 +16,8 @@ class Public::Api::V1::Portals::ArticlesController < PublicController | |||||||
|  |  | ||||||
|   def set_article |   def set_article | ||||||
|     @article = @category.articles.find(params[:id]) |     @article = @category.articles.find(params[:id]) | ||||||
|  |     @article.views = @article.views ? @article.views + 1 : 1 | ||||||
|  |     @article.save | ||||||
|     @parsed_content = render_article_content(@article.content) |     @parsed_content = render_article_content(@article.content) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -30,7 +30,7 @@ | |||||||
|     </td> |     </td> | ||||||
|     <td> |     <td> | ||||||
|       <span class="fs-small"> |       <span class="fs-small"> | ||||||
|         {{ readCount }} |         {{ views || 0 }} | ||||||
|       </span> |       </span> | ||||||
|     </td> |     </td> | ||||||
|     <td> |     <td> | ||||||
| @@ -76,7 +76,7 @@ export default { | |||||||
|       type: Object, |       type: Object, | ||||||
|       default: () => {}, |       default: () => {}, | ||||||
|     }, |     }, | ||||||
|     readCount: { |     views: { | ||||||
|       type: Number, |       type: Number, | ||||||
|       default: 0, |       default: 0, | ||||||
|     }, |     }, | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|           :title="article.title" |           :title="article.title" | ||||||
|           :author="article.author" |           :author="article.author" | ||||||
|           :category="article.category" |           :category="article.category" | ||||||
|           :read-count="article.readCount" |           :views="article.views" | ||||||
|           :status="article.status" |           :status="article.status" | ||||||
|           :updated-at="article.updated_at" |           :updated-at="article.updated_at" | ||||||
|         /> |         /> | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ export default { | |||||||
|         type: 'text', |         type: 'text', | ||||||
|       }, |       }, | ||||||
|     }, |     }, | ||||||
|     readCount: { |     views: { | ||||||
|       defaultValue: 13, |       defaultValue: 13, | ||||||
|       control: { |       control: { | ||||||
|         type: 'number', |         type: 'number', | ||||||
| @@ -57,7 +57,7 @@ ArticleItem.args = { | |||||||
|     name: 'John Doe', |     name: 'John Doe', | ||||||
|   }, |   }, | ||||||
|   category: 'Getting started', |   category: 'Getting started', | ||||||
|   readCount: 12, |   views: 12, | ||||||
|   status: 'published', |   status: 'published', | ||||||
|   updatedAt: 1657255863, |   updatedAt: 1657255863, | ||||||
| }; | }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 GitStart
					GitStart