Back to Parent

def determine_random_project x   
     
    input = x
    
    match_project_NAMEADDR = []
    match_project_BESTSTAT = []
    match_project_DBIDESC = []

    file= File.read('SF_Development_Pipeline_2018_Q2_AWedit.json')
        all_projects=JSON.parse(file)
            all_projects.each do |row|
                if row["NAMEADDR"]!= 0
                    if row["PD"].to_s == session["PD"]  
                        match_project_NAMEADDR.push(row["NAMEADDR"])                
                        match_project_BESTSTAT.push(row["BESTSTAT"])
                        match_project_DBIDESC.push(row["DBIDESC"])
                    else 
                        match_project_NAMEADDR.push(row["NAMEADDR"])                
                        match_project_BESTSTAT.push(row["BESTSTAT"])
                        match_project_DBIDESC.push(row["DBIDESC"])
                    end
                end
             end
        
    
    
    sum_match_project = match_project_NAMEADDR.count
    random_n = rand(sum_match_project)
    random_proj_NAMEADDR = match_project_NAMEADDR[random_n].downcase.strip
    random_proj_BESTSTAT = match_project_BESTSTAT[random_n].downcase.strip
    random_proj_DBIDESC = match_project_DBIDESC[random_n].downcase.strip



    # ================= print result – start =================
    #if I have time i'd add conditions to fix the phrase before "beststat"
    random_proj_NAMEADDR + ", currently under the status " + random_proj_BESTSTAT + ", will " + random_proj_DBIDESC + ". "    
    # ================= print result – end =================
    
end
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0