gd_bam 0.1.21 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/bam/version.rb +1 -1
 - data/lib/cloud_connect/dsl/sf_helpers.rb +22 -20
 - data/lib/generators/downloaders.rb +12 -3
 - data/lib/generators/etl.rb +2 -1
 - metadata +2 -2
 
    
        data/lib/bam/version.rb
    CHANGED
    
    
| 
         @@ -25,31 +25,33 @@ module GoodData 
     | 
|
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                  def self.generate_incremental_select(tap)
         
     | 
| 
       27 
27 
     | 
    
         
             
                    if tap[:condition].blank?
         
     | 
| 
       28 
     | 
    
         
            -
                      tap[:condition] = "SystemModstamp > ${#{tap[:id]}_START} 
     | 
| 
      
 28 
     | 
    
         
            +
                      tap[:condition] = "SystemModstamp > ${#{tap[:id]}_START}"
         
     | 
| 
      
 29 
     | 
    
         
            +
                      # AND SystemModstamp <= ${#{tap[:id]}_END}
         
     | 
| 
       29 
30 
     | 
    
         
             
                    else
         
     | 
| 
       30 
     | 
    
         
            -
                      tap[:condition] += " AND SystemModstamp > ${#{tap[:id]}_START} 
     | 
| 
      
 31 
     | 
    
         
            +
                      tap[:condition] += " AND SystemModstamp > ${#{tap[:id]}_START}"
         
     | 
| 
      
 32 
     | 
    
         
            +
                       # AND SystemModstamp <= ${#{tap[:id]}_END}
         
     | 
| 
       31 
33 
     | 
    
         
             
                    end
         
     | 
| 
       32 
34 
     | 
    
         
             
                    generate_select(tap)
         
     | 
| 
       33 
35 
     | 
    
         
             
                  end
         
     | 
| 
       34 
36 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
                  def self.generate_history_query(client, field, sf_object, for_sf_object)
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
                  # def self.generate_history_query(client, field, sf_object, for_sf_object)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  #   fields = client.fields(sf_object)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  #   generic_field_history = ["NewValue", "OldValue", "ParentId"].all? {|f| fields.include?(f)}
         
     | 
| 
      
 40 
     | 
    
         
            +
                  #   specific_field_history = ["NewValue", "OldValue", "#{for_sf_object}Id"].all? {|f| fields.include?(f)}
         
     | 
| 
      
 41 
     | 
    
         
            +
                  #   specific_history = ["SystemModstamp", "#{for_sf_object}Id"].all? {|f| fields.include?(f)}
         
     | 
| 
      
 42 
     | 
    
         
            +
                  #   
         
     | 
| 
      
 43 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 44 
     | 
    
         
            +
                  #   if generic_field_history
         
     | 
| 
      
 45 
     | 
    
         
            +
                  #     "SELECT NewValue, CreatedDate, ParentId FROM #{sf_object} WHERE Field = '#{field}'"
         
     | 
| 
      
 46 
     | 
    
         
            +
                  #   elsif specific_field_history
         
     | 
| 
      
 47 
     | 
    
         
            +
                  #     "SELECT NewValue, CreatedDate, ParentId FROM #{sf_object} WHERE Field = '#{field}'"
         
     | 
| 
      
 48 
     | 
    
         
            +
                  #   elsif specific_history
         
     | 
| 
      
 49 
     | 
    
         
            +
                  #     return nil unless fields.include?(field)
         
     | 
| 
      
 50 
     | 
    
         
            +
                  #     "SELECT #{field}, SystemModstamp, #{for_sf_object}Id FROM #{sf_object}"
         
     | 
| 
      
 51 
     | 
    
         
            +
                  #   else
         
     | 
| 
      
 52 
     | 
    
         
            +
                  #     fail "Unrecognized fields configuration for historization in SF."
         
     | 
| 
      
 53 
     | 
    
         
            +
                  #   end
         
     | 
| 
      
 54 
     | 
    
         
            +
                  # end
         
     | 
| 
       53 
55 
     | 
    
         | 
| 
       54 
56 
     | 
    
         
             
                  def self.sf_connection(builder, data)
         
     | 
| 
       55 
57 
     | 
    
         
             
                    builder.Connection({
         
     | 
| 
         @@ -35,9 +35,9 @@ module GoodData 
     | 
|
| 
       35 
35 
     | 
    
         | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
                        normalize_code = <<HEREDOC
         
     | 
| 
       38 
     | 
    
         
            -
            boolean done = false;
         
     | 
| 
       39 
38 
     | 
    
         
             
            function integer count() {
         
     | 
| 
       40 
39 
     | 
    
         | 
| 
      
 40 
     | 
    
         
            +
              // This would run for the first time since we do not have anything stored in the custom properties hash
         
     | 
| 
       41 
41 
     | 
    
         
             
              if (indexOf($in.0.key, "#{dataset}_LAST_RUN") != -1) {
         
     | 
| 
       42 
42 
     | 
    
         
             
                return 4;
         
     | 
| 
       43 
43 
     | 
    
         
             
              }
         
     | 
| 
         @@ -47,17 +47,26 @@ function integer count() { 
     | 
|
| 
       47 
47 
     | 
    
         
             
            }
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
       49 
49 
     | 
    
         
             
            string last_run = null;
         
     | 
| 
      
 50 
     | 
    
         
            +
            long last_run_ts = null;
         
     | 
| 
       50 
51 
     | 
    
         
             
            string end_date = null;
         
     | 
| 
      
 52 
     | 
    
         
            +
            long now = date2long(today());
         
     | 
| 
      
 53 
     | 
    
         
            +
            long ten_mins_ago = now - (60 * 10) ;
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
       51 
55 
     | 
    
         | 
| 
       52 
56 
     | 
    
         
             
            function integer transform(integer idx) {
         
     | 
| 
       53 
57 
     | 
    
         
             
              if (last_run == null) {
         
     | 
| 
       54 
58 
     | 
    
         
             
                last_run = $in.0.value;
         
     | 
| 
      
 59 
     | 
    
         
            +
                last_run_ts = date2long(jodaStr2date(last_run, ["yyyy-MM-dd'T'HH:mm:ss.SSSZZ"], 'en_US', 'UTC', 'UTC'));
         
     | 
| 
       55 
60 
     | 
    
         
             
              }
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
       56 
62 
     | 
    
         
             
              if (end_date == null) {
         
     | 
| 
       57 
     | 
    
         
            -
                 
     | 
| 
      
 63 
     | 
    
         
            +
                if (ten_mins_ago < last_run_ts) {
         
     | 
| 
      
 64 
     | 
    
         
            +
                  end_date = jodaDate2str(long2date(last_run_ts), "yyyy-MM-dd'T'HH:mm:ss.SSSZZ", "en_US", 'UTC');
         
     | 
| 
      
 65 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 66 
     | 
    
         
            +
                  end_date = jodaDate2str(long2date(ten_mins_ago), "yyyy-MM-dd'T'HH:mm:ss.SSSZZ", "en_US", 'UTC');
         
     | 
| 
      
 67 
     | 
    
         
            +
                }
         
     | 
| 
       58 
68 
     | 
    
         
             
              }
         
     | 
| 
       59 
69 
     | 
    
         | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
70 
     | 
    
         
             
              if (idx == 1) {
         
     | 
| 
       62 
71 
     | 
    
         
             
                $out.0.all = "#{dataset}_TRUNCATE_DATE=" + jodaDate2str(jodaStr2date(last_run, ["yyyy-MM-dd'T'HH:mm:ss.SSSZZ"], 'en_US', 'UTC', 'UTC'), "yyyy-MM-dd HH:mm:ss", 'en_US', 'UTC');
         
     | 
| 
       63 
72 
     | 
    
         
             
              } else if (idx == 2) {
         
     | 
    
        data/lib/generators/etl.rb
    CHANGED
    
    | 
         @@ -278,10 +278,11 @@ HEREDOC 
     | 
|
| 
       278 
278 
     | 
    
         
             
                              Core::build_node2(builder, Nodes.es_reader2({:name => "ES Reader", :id => "es", :entityFieldsMapping => stuff.to_json , :readMap => read_map.to_json, :timeIntervals => time_frames.to_json}))
         
     | 
| 
       279 
279 
     | 
    
         
             
                            end
         
     | 
| 
       280 
280 
     | 
    
         | 
| 
      
 281 
     | 
    
         
            +
                            
         
     | 
| 
       281 
282 
     | 
    
         
             
                            transformation_source = if Metadata::has_field?(metadata_from_es, "Snapshot")
         
     | 
| 
       282 
283 
     | 
    
         
             
                              "function integer transform() {\n" + (Tap.source_target_mappging(tap).map {|t| "$out.0.#{t.last} = $in.0.#{t.first};"}.join("\n")) + "\n$out.0.Snapshot = date2str(dateAdd(str2date(\"1900-01-01\", \"yyyy-MM-dd\"),  str2long($in.0.Snapshot), day), \"yyyy-MM-dd\");\nreturn OK;\n}"
         
     | 
| 
       283 
284 
     | 
    
         
             
                            else
         
     | 
| 
       284 
     | 
    
         
            -
                              " 
     | 
| 
      
 285 
     | 
    
         
            +
                              "long count = 0;\nfunction integer transform() {\ncount = count + 1; if (count == 1) {return SKIP;}\n" + (Tap.source_target_mappging(tap).map {|t| "$out.0.#{t.last} = $in.0.#{t.first};"}.join("\n")) + "\nreturn OK;\n}"
         
     | 
| 
       285 
286 
     | 
    
         
             
                            end
         
     | 
| 
       286 
287 
     | 
    
         
             
                            Core::build_node2(builder, Nodes.reformat2({:name => "Reformat", :id => "reformat", :transformation => transformation_source}))
         
     | 
| 
       287 
288 
     | 
    
         
             
                            Core::build_node2(builder, Nodes.edge2({:toNode => "reformat:0", :fromNode => "es:0", :metadata => "es_metadata"}))
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: gd_bam
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.22
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2013-08- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2013-08-16 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: rake
         
     |