• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

foodcoops / foodsoft / 19213239496

09 Nov 2025 07:18PM UTC coverage: 50.014% (-17.1%) from 67.092%
19213239496

push

github

web-flow
doc: Fix URL for CI/CD deployment in README

3605 of 7208 relevant lines covered (50.01%)

15.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

25.0
/app/controllers/api/v1/articles_controller.rb
1
class Api::V1::ArticlesController < Api::V1::BaseController
1✔
2
  skip_before_action :authenticate
1✔
3

4
  def index
1✔
5
    supplier = Supplier.find_by_external_uuid!(index_params.fetch(:shared_supplier_uuid))
×
6

7
    @articles = Article.with_latest_versions_and_categories.undeleted.where(supplier_id: supplier, type: nil)
×
8
    @articles = @articles.where('article_versions.updated_at > ?', index_params[:updated_after].to_datetime) if index_params.include?(:updated_after)
×
9
    @articles = @articles.where('article_versions.name LIKE ?', "%#{index_params[:name]}%") if index_params.include?(:name)
×
10
    @articles = @articles.where(article_versions: { origin: index_params[:origin] }) if index_params.include?(:origin)
×
11
    @articles = @articles.where(article_versions: { order_number: index_params[:order_numbers] }) if index_params.include?(:order_numbers)
×
12
    @articles = @articles.page(index_params[:page]).per(index_params.fetch(:per_page)) if index_params.include?(:page)
×
13

14
    data = @articles.map { |article| get_article_version_data(article) }
×
15

16
    render json: { articles: data, pagination: pagination_response, latest_update: get_latest_article_update(supplier) }
×
17
  end
18

19
  protected
1✔
20

21
  def index_params
1✔
22
    params.permit(:shared_supplier_uuid, :updated_after, :name, :origin, :page, :per_page, order_numbers: [])
×
23
  end
24

25
  def get_article_version_data(article)
1✔
26
    version_attributes = article.latest_article_version.attributes
×
27
    version_attributes.delete_if { |key| key == 'id' || key.end_with?('_id') }
×
28

29
    version_attributes['article_unit_ratios'] = article.latest_article_version.article_unit_ratios.map do |ratio|
×
30
      ratio_attributes = ratio.attributes
×
31
      ratio_attributes.delete_if { |key| key == 'id' || key.end_with?('_id') }
×
32
    end
33

34
    version_attributes
×
35
  end
36

37
  def get_latest_article_update(supplier)
1✔
38
    latest_update = Article
×
39
                    .with_latest_versions
40
                    .undeleted
41
                    .where(supplier_id: supplier, type: nil)
42
                    .order('article_versions.updated_at DESC')
43
                    .limit(1)
44
                    .first&.updated_at
45
    latest_update&.utc
×
46
  end
47

48
  def pagination_response
1✔
49
    return nil unless index_params.include?(:page)
×
50

51
    current = @articles.current_page
×
52
    total = @articles.total_pages
×
53
    {
54
      current_page: current,
×
55
      previous_page: (current > 1 ? (current - 1) : nil),
×
56
      next_page: (current == total ? nil : (current + 1)),
×
57
      per_page: @articles.limit_value,
58
      total_pages: total,
59
      number: @articles.total_count
60
    }
61
  end
62
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc