Sha256: ebc660f6a542f973c00b9068d27680e5d16fd75f45c33c42d9f954f353616dec
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Dhis2 class Status attr_reader :raw_status def initialize(raw_status) @raw_status = raw_status end def success? if @raw_status["import_type_summaries"] return @raw_status["import_type_summaries"].all? do |summary| summary["status"] == "SUCCESS" end end %w[SUCCESS OK].include?(@raw_status["status"]) end def total_imported total = 0 if @raw_status["import_count"] @raw_status["import_count"].each do |_, count| total += count end elsif @raw_status["type_reports"] total += @raw_status["type_reports"].first["stats"]["total"] end total end def last_imported_ids return [] unless @raw_status["import_type_summaries"] @raw_status["import_type_summaries"].map { |summary| summary["last_imported"] } end def import_summaries return [] unless @raw_status["response"]["import_summaries"] @raw_status["response"]["import_summaries"].map { |it| OpenStruct.new(it) } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dhis2-2.3.8 | lib/dhis2/status.rb |
dhis2-2.3.7 | lib/dhis2/status.rb |
dhis2-2.3.6 | lib/dhis2/status.rb |