aboutsummaryrefslogtreecommitdiff
blob: e2c82f93ac15eaba414f6cb67dc30dda9534f8bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
@feed_id ||= nil

atom_feed(id: atom_id(@feed_type, @feed_id, 'feed')) do |feed|
  all_packages = PackageRepository.default_search(@query, 0, 10_000)

  feed.title @feed_title
  feed.updated !all_packages.empty? ? all_packages.first.created_at : Time.zone.now

  feed.author do |author|
    author.name 'Gentoo Packages Database'
  end

  all_packages.each do |package|
    atom = package.atom

    commit = CommitRepository.find_sorted_by :packages, atom, :committer_date, 'desc', 1
    commit = commit.first

    if package.nil?
      logger.warn 'Package nil!'
      next
    end

    id = atom

    feed.entry(
      package,
      id: atom_id(@feed_type, @feed_id, id),
      url: absolute_link_to_package(atom)
    ) do |entry|
      entry.updated commit ? commit.author_date.to_datetime.rfc3339 : Time.now.to_datetime.rfc3339

      entry.title(t(:feed_keyworded_title,
                    atom: atom,
                    description: package.description))
      entry.content(t(:feed_commit_content,
                      hash: commit ? commit.id[0..6] : '',
                      message: commit ? commit.message : 'No commit available'))
    end
  end
end