■ ■ ■ ■ ■ ■
backend/app/models/subdomain.rb
| skipped 1 lines |
2 | 2 | | belongs_to :domain |
3 | 3 | | |
4 | 4 | | scope :filtered_by_subdomain, ->(subdomain) { where('url LIKE ?', "%#{subdomain}%") } |
5 | | - | scope :filtered_by_technology, lambda { |technology| |
6 | | - | subdomains = [] |
7 | | - | |
8 | | - | self.each do |subdomain| |
9 | | - | technologies = subdomain.infos['technologies'] |
10 | | - | next if technologies.empty? |
11 | | - | |
12 | | - | technologies.each do |tech| |
13 | | - | next unless tech['name'] == technology |
14 | | - | |
15 | | - | subdomains << subdomain |
16 | | - | end |
17 | | - | end |
18 | | - | |
19 | | - | subdomains |
20 | | - | } |
| 5 | + | scope :filtered_by_technology, ->(technology) { where('infos @> ?', "{\"technologies\": [{\"name\":\"#{technology}\"}]}") } |
21 | 6 | | scope :filtered_by_status_code, ->(status_code) { where('infos @> ?', "{\"status_code\": #{status_code}}") if status_code.to_i > 0 } |
22 | 7 | | end |
23 | 8 | | |