/config.rb (22d80d32c1036d9629bf3121812518e650c573ab) (5758 bytes) (mode 100644) (type blob)

require 'redis'
require 'ostruct'
require 'json'

CONFIG = OpenStruct.new
CONFIG.redis_db_index = 1
CONFIG.redis = Redis.new(:db => CONFIG.redis_db_index)


CONFIG.graph_index_key	     = 'all_graphs'

# initialise octothorpes
CONFIG.info_index_key        = Hash.new
CONFIG.node_index_key        = Hash.new
CONFIG.metric_index_key      = Hash.new
CONFIG.score_index_key       = Hash.new
CONFIG.percolation_index_key = Hash.new
CONFIG.layout_index_key      = Hash.new

CONFIG.node_neighbors_prefix = Hash.new
CONFIG.node_prefix           = Hash.new
CONFIG.metric_prefix         = Hash.new
CONFIG.score_prefix          = Hash.new
CONFIG.statistics_prefix     = Hash.new
CONFIG.percolation_prefix    = Hash.new

CONFIG.metric_names	     = Hash.new
CONFIG.score_names	     = Hash.new
CONFIG.percolation_methods   = Hash.new
CONFIG.percolation_pctages   = Hash.new
CONFIG.layout_names          = Hash.new

CONFIG.all_graphs = CONFIG.redis.smembers(CONFIG.graph_index_key)


# for each graph in all_graphs
CONFIG.all_graphs.each do |graph|
  
  CONFIG.info_index_key.store(graph, graph+':'+'general_info')
  CONFIG.node_index_key.store(graph, graph+':'+'all_nodes')
  CONFIG.metric_index_key.store(graph, graph+':'+'all_metrics')
  CONFIG.score_index_key.store(graph, graph+':'+'all_scores')
  CONFIG.percolation_index_key.store(graph, graph+':'+'all_percolation_modes')
  CONFIG.layout_index_key.store(graph,graph+':'+'all_layouts')

  CONFIG.node_neighbors_prefix.store(graph, graph+':'+'node_neighbors:')
  CONFIG.node_prefix.store(graph, graph+':'+'node_metrics:')
  CONFIG.metric_prefix.store(graph, graph+':'+'metric:')
  CONFIG.score_prefix.store(graph, graph+':'+'score:')
  CONFIG.statistics_prefix.store(graph, graph+':'+'statistics:')
  CONFIG.percolation_prefix.store(graph, graph+':'+'percolation:')

  #automatic retrieval and naive naming of available metrics from Redis
  CONFIG.metric_names[graph] = CONFIG.redis.smembers(CONFIG.metric_index_key[graph]).inject({}) do |h,metric|
    h[metric] = metric.split('_').map(&:capitalize).join(' ')
    h
  end

  #CONFIG.metric_names = {
  #  'clustering_coefficient'                      => "Clustering Coefficient",
  #  'corrected_clustering_coefficient'            => "Clustering Coefficient (Corrected)",
  #  'degree'                                      => "Node Degree",
  #  'average_neighbor_degree'                     => "Average Neighbor Degree",
  #  'corrected_average_neighbor_degree'           => "Average Neighbor Degree (Corrected)",
  #  'iterated_average_neighbor_degree'            => "Iterated Average Neighbor Degree",
  #  'corrected_iterated_average_neighbor_degree'  => "Iterated Average Neighbor Degree (Corrected)",
  #  'betweenness_centrality'                      => "Betweenness Centrality",
  #  'eccentricity'                                => "Eccentricity",
  #  'average_shortest_path_length'                => "Average Shortest Path Length"
  #}


  #automatic retrieval and naive naming of available scores from Redis
  CONFIG.score_names[graph] = CONFIG.redis.smembers(CONFIG.score_index_key[graph]).inject({}) do |h,score|
    h[score] = score.split('_').map(&:capitalize).join(' ')
    h
  end
  
  # scores have to be readable in redis
  #CONFIG.score_names = {
  #  'unified_risk_score'                => "Unified Risk Score (URS)",
  #  'advanced_unified_risk_score'       => "Advanced URS"
  #}
  
  
  #puts JSON.parse(CONFIG.redis.smembers(CONFIG.node_index_key[graph]).to_s)
  
  
  #automatic retrieval and naive naming of available percolation methods from Redis
  CONFIG.percolation_methods[graph] = CONFIG.redis.smembers(CONFIG.percolation_index_key[graph]).inject({}) do |h,method|
   # h[method] = method.split(':').map{|string| string.capitalize}.join(' - ').split('_').map(&:capitalize).join(' ')
    h[method] = method.split(':').map{|string| string.split('_').map(&:capitalize).join(' ')}.join(' - ')
    h
  end
  
  #retrieval of percolation percentages
  CONFIG.percolation_pctages[graph] = CONFIG.redis.hget(CONFIG.info_index_key[graph], 'percentages').split(';')
  
  #automatic retrieval and naive naming of available layouts from Redis
  CONFIG.layout_names[graph] = CONFIG.redis.smembers(CONFIG.layout_index_key[graph]).inject({}) do |h,layout|
    h[layout] = layout.split('_').map(&:capitalize).join(' ')
    h
  end

end

CONFIG.normalization_suffix  = '_normalized'

CONFIG.statistical_indicators = { 'min'                 => "Minimum",
                                  'max'                 => "Maximum",
                                  'average'             => "Average Value" ,
                                  'median'              => "Median Value",
                                  'standard_deviation'  => "Standard Deviation"}

# css classes for status indication ordered from "good" to "bad"
CONFIG.color_classes = ['success','info', 'warning', 'danger']

#HTML color codes from green to red in 0x11-steps
CONFIG.color_codes = ['#FF0000','#FF1100','#FF2200','#FF3300','#FF4400',
                      '#FF5500','#FF6600','#FF7700','#FF8800','#FF9900',
                      '#FFAA00','#FFBB00','#FFCC00','#FFDD00','#FFEE00',
                      '#FFFF00','#EEFF00','#DDFF00','#CCFF00','#BBFF00',
                      '#AAFF00','#99FF00','#88FF00','#77FF00','#66FF00',
                      '#55FF00','#44FF00','#33FF00','#22FF00','#11FF00',
                      '#00FF00'].reverse

#can be metric or score
CONFIG.node_coloring_field = 'unified_risk_score'

# max number of neighbors for graphical representation with d3.js
CONFIG.max_graph_neighbors = 150
CONFIG.nodes_per_page = 25


Mode Type Size Ref File
100644 blob 32 02d771bb174550ee73ca245d5452a371c7ff568e Gemfile
100644 blob 71 5a0b34f4c7ea7ff499826db4642432a1e5940c5d Gemfile.lock
100644 blob 79 04e9bf5219f1065f2d2f20519a988f41a274d7d9 README.md
100644 blob 494 9eca68213c93af98fde713132b619df2393bbd39 color_helper.rb
100644 blob 5758 22d80d32c1036d9629bf3121812518e650c573ab config.rb
100644 blob 231 3a145ad82816a6a5ff94d25c6f0f555dc8a89910 index.rb
100644 blob 616 27c598cf96f2f8a8cd59b771096e781a486d3d52 metric_routes.rb
100644 blob 2155 083df9b345eb65f5367541d747e26b32447a98f3 node_routes.rb
100644 blob 2230980 5dadf2edab67df737f2d86e2c4790b110230a064 nohup.out
100644 blob 649 e7daa8d38b126863ae1e75d2bc738e3b13c47fe6 percolation_routes.rb
040000 tree - 118a9bd7235757f947a5fccc49084c45e51e92db public
100755 blob 317 e674f04472635862c107448bd013e91fa68a4acf run.rb
100644 blob 546 bed129cf69ccede24d821dd48c9dba0a5fef44be score_routes.rb
100755 blob 53 1f1911e7f2691de68e0331d32d57fbf1101bebe5 start_run.rb.sh
100644 blob 493 07311526c68d9a623caa01ddecff1cccb8b0ae7e statistics_routes.rb
100644 blob 7466 0e13f2a7785f5afd3d7bb8ac9acdf775987d4e97 storage.rb
100644 blob 104 dd18016d10c430cc64dfe5a3ff97ae7f859ea991 test.rb
100644 blob 5111 7986577b4c94bca4a9b464d04ed0dbda6d124d48 test_config.rb
040000 tree - 14484f653711cb6dd995ebf5ed61274b85efc2a6 views
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/coria/coria-frontend

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/coria/coria-frontend

Clone this repository using git:
git clone git://git.rocketgit.com/user/coria/coria-frontend

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main