json_history_update.rb
# queries GitHub, adds or updates data
queries GitHub, adds or updates data
queries GitHub adds or updates data
def update_data(type1, filter)
      type2 = type1 == :pr ? :pullRequests : :issues
      query = gql_query_str type2, filter
      body = gql_request query
      ary = body.dig :data, :repository, type2, :edges
      print_error(body, query) unless ary
      ary.each do |h|
        item = h[:node]
        key = item[:number].to_s
        if @data.key? key
          unless item[:closedAt].nil? || @data[key]['closed'] == item[:closedAt]
            @updated += 1
            puts format "#{type1} %5s updated in data", key
            @data[key] = create_obj item, type1
          end
        else
          @added += 1
          puts format "#{type1} %5s added in data", key
          @data[key] = create_obj item, type1
        end
      end
    end
def update_data ( type1 , filter ) type2 = type1 == :pr ? :pullRequests : :issues query = gql_query_str type2 , filter body = gql_request query ary = body . dig :data , :repository , type2 , :edges print_error ( body , query ) unless ary ary . each do | h | item = h [ :node ] key = item [ :number ] . to_s if @data . key? key unless item [ :closedAt ] . nil? || @data [ key ] [ 'closed' ] == item [ :closedAt ] @updated += 1 puts format "#{type1} %5s updated in data" , key @data [ key ] = create_obj item , type1 end else @added += 1 puts format "#{type1} %5s added in data" , key @data [ key ] = create_obj item , type1 end end end
queries GitHub, adds or updates data
queries GitHub adds or updates data
type1
<not_specific>
filter
<not_specific>