This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Relationship < ApplicationRecord | |
belongs_to :outage | |
belongs_to :child | |
validate :outage_changed, if: :outage_id_changed? | |
private | |
def outage_changed | |
Relationship.where(child_id: self.child_id).update_all(outage_id: self.outage_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Child < ApplicationRecord | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Child < ApplicationRecord | |
has_many :relationships | |
has_many :outages, through: :relationships | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= collection_check_boxes(:outage, :child_ids, Child.all.map{|c| c.omnia_trouble_ticket if !c.relationships.present?}, :id, :omnia_trouble_ticket) do |b| %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for @relationship, :url => relationships_path do |f| %> | |
<%= f.text_field :child_id %> | |
<%= f.text_field :outage_id %> | |
<%= f.submit %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Outage < ApplicationRecord | |
has_many :relationships | |
has_many :children, through: :relationships | |
end | |
class Child < ApplicationRecord | |
has_many :relationships | |
has_many :outages, through: :relationships | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Child < ApplicationRecord | |
has_one :outage, through: :relationship | |
has_one :relationship | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_csv | |
url = "http://localhost:3000" | |
doc = Nokogiri::HTML(open(url, :allow_redirections => :safe)) | |
csv = CSV.open("#{Rails.root}/public/collections-output.csv", 'w',{:col_sep => ","}) | |
csv << ['HEADERS HERE'] | |
doc.xpath('//table/tbody/tr').each do |row| | |
tarray = [] | |
row.xpath('td').each do |cell| | |
tarray << cell.text | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum_close | |
daily_closed_tickets = Fst.sum_retrieve_closed_tickets | |
daily_closed_tickets.each do |ticket| | |
CSV.open("/var/www/html/harmonize/public/close/CLOSED_#{ticket.attributes['TroubleTicketNumber']}_sum.txt", "w+", {force_quotes: false}) do |csv| | |
if (ticket.attributes['ClosedDate'].present? && ticket.attributes['CauseCode'].present? && (FileCopyReceipt.exists?(path: "/var/www/html/harmonize/public/open/OPEN_#{ticket.attributes['TroubleTicketNumber']}_sum.txt"))) | |
csv << ["GENERATE CSV WITH ATTRIBUTES HERE"] | |
files = Dir.glob("/var/www/html/harmonize/public/close/CLOSED_#{ticket.attributes['TroubleTicketNumber']}_sum.txt") | |
files.each do |f| | |
Rails.logger.info "CHECKING SUM PATH (should be false): #{FileCopyReceipt.exists?(path: f)}" | |
Rails.logger.info "File size (should return non-0): #{File.size(f)}" #returns 0, but not in Rails Console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE [OMNIA_ESUM_P_SUM_CM] | |
GO | |
/****** Object: StoredProcedure [dbo].[SUM_Harmonize_Clear_SP] Script Date: 8/30/2017 10:28:39 AM ******/ | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO |