dataduck 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bd5effb261990d6eccb37fe16de93195c89ef24
4
- data.tar.gz: b2c7d31fac424890e6b605d2828423b624625467
3
+ metadata.gz: 5944e3a23d61e1bcdbfa5c82e1a8d0ee3fe8b4cf
4
+ data.tar.gz: 70c2e2b7af5377e13f473a9f7f56df438e5b6491
5
5
  SHA512:
6
- metadata.gz: 61b17cc19b83ad9733b9744de6a65f884af5f3b145ddbc967ce01eff2fa8b552b103c9c69016c59f87c729cd9bc10866ed5ee720f903236c90e1d2b4ec2712c5
7
- data.tar.gz: 0217b069e2d3997698c4135a170c65c22d16187cb02d35adf68d4e62c8798073c2c95a9d5f9689329762cc8c6d25a0b5682f542f7b802918a6776f792e302db3
6
+ metadata.gz: af935179e9a4a52d56423cb2a785db6d51421caaaba6d5fa33b6283708b6199252770892446b394c826fab07d75e57553c43d8ccf15754156fe063fc48732e54
7
+ data.tar.gz: 51ef2d29c8092aaf30e65326701ed3936c3e77a745ad171dbfd6d993c608e2312344258b31f0c525dd607739ae4376471ef3017858fbb50e6772bf4481b4b263
@@ -146,7 +146,7 @@ module DataDuck
146
146
  end
147
147
  end
148
148
 
149
- if base_query.downcase.include?(' where ')
149
+ if base_query.downcase.split("from").last.include?(' where ')
150
150
  extract_part.gsub!('WHERE ', 'AND ')
151
151
  end
152
152
 
@@ -2,7 +2,7 @@ module DataDuck
2
2
  if !defined?(DataDuck::VERSION)
3
3
  VERSION_MAJOR = 0
4
4
  VERSION_MINOR = 6
5
- VERSION_PATCH = 6
5
+ VERSION_PATCH = 7
6
6
  VERSION = [VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH].join('.')
7
7
  end
8
8
  end
@@ -4,6 +4,8 @@ require 'uri'
4
4
 
5
5
  module DataDuck
6
6
  module SEMRush
7
+ class OrganicResultsAPIError < Exception; end
8
+
7
9
  class OrganicResults < DataDuck::IntegrationTable
8
10
  def display_limit
9
11
  20
@@ -29,7 +31,11 @@ module DataDuck
29
31
  self.data = []
30
32
 
31
33
  self.phrases.each do |phrase|
32
- self.extract_results_for_keyword_and_date!(phrase)
34
+ begin
35
+ self.extract_results_for_keyword_and_date!(phrase)
36
+ rescue OrganicResultsAPIError => err
37
+ DataDuck::Logs.error(err)
38
+ end
33
39
  end
34
40
  end
35
41
 
@@ -39,9 +45,15 @@ module DataDuck
39
45
  escaped_phrase = URI.escape(phrase)
40
46
  semrush_api_url = "http://api.semrush.com/?type=phrase_organic&key=#{ self.key }&display_limit=#{ self.display_limit }&export_columns=Dn,Ur&phrase=#{ escaped_phrase }&database=#{ self.search_database }"
41
47
 
48
+ puts semrush_api_url
49
+
42
50
  response = Typhoeus.get(semrush_api_url)
43
51
  if response.response_code != 200
44
- raise Exception.new("SEMrush API returned error #{ response.response_code} #{ response.body }")
52
+ raise OrganicResultsAPIError.new("SEMrush API for phrase #{ phrase } returned error #{ response.response_code } #{ response.body }")
53
+ end
54
+
55
+ if response.body.start_with?("ERROR ")
56
+ raise OrganicResultsAPIError.new("SEMrush API for phrase #{ phrase } returned 200 but with a body stating #{ response.body }")
45
57
  end
46
58
 
47
59
  rank = -1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dataduck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Pickhardt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-07 00:00:00.000000000 Z
11
+ date: 2015-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler