/app/controllers/administrator/stats_controller.rb

https://github.com/EOL/capstone_eol · Ruby · 76 lines · 63 code · 12 blank · 1 comment · 10 complexity · 5f5644b68673a186ae30a8156de1d54d MD5 · raw file

  1. class Administrator::StatsController < AdminController
  2. layout :choose_layout
  3. before_filter :restrict_to_admins
  4. def index
  5. @reports_list = [["--select--",""],
  6. ["EOL Web Usage Statistics","http://services.eol.org/eol_php_code/applications/google_stats/index.php"],
  7. ["EOL Names Stat","http://services.eol.org/names_stat/"],
  8. ["EOL Transfer Schema XML Validator","http://services.eol.org/validator/"],
  9. ["UBio-FindIT for URL lists","http://services.eol.org/urls_lookup/"],
  10. ]
  11. @report_url = params[:report_url] || @reports_list[1][1]
  12. @google_stat_year_list = get_google_stat_year_list
  13. end
  14. def SPM_objects_count
  15. @page_title = I18n.t("species_profile_model_dato_count_title")
  16. @arr_SPM = InfoItem.get_schema_value
  17. @rec = PageStatsTaxon.latest
  18. if(@rec["data_objects_count_per_category"] != "[DATA MISSING]" and @rec["data_objects_count_per_category"] != nil) then
  19. @arr_count = JSON.parse(@rec["data_objects_count_per_category"])
  20. else
  21. @arr_count = nil
  22. end
  23. end
  24. def SPM_partners_count
  25. @page_title = I18n.t("species_profile_model_cp_count_title")
  26. @arr_SPM = InfoItem.get_schema_value
  27. @rec = PageStatsTaxon.latest
  28. if(@rec["content_partners_count_per_category"] != "[DATA MISSING]" and @rec["content_partners_count_per_category"] != nil) then
  29. @arr_count = JSON.parse(@rec["content_partners_count_per_category"])
  30. else
  31. @arr_count = nil
  32. end
  33. end
  34. def toc_breakdown
  35. @page_title = I18n.t("table_of_contents_breakdown_title")
  36. @all_toc_items = TocItem.find(:all, :include => [ :parent, :info_items ], :order => 'view_order')
  37. end
  38. def content_taxonomic
  39. if params[:hierarchy_id]
  40. @hierarchy = Hierarchy.find(params[:hierarchy_id])
  41. else
  42. @browsable_hierarchies = Hierarchy.browsable_by_label
  43. end
  44. end
  45. private
  46. # Note this runs AFTER the action... so we may already have a @page_title by the time we get here.
  47. def choose_layout
  48. @page_title ||= $ADMIN_CONSOLE_TITLE
  49. @navigation_partial = '/admin/navigation'
  50. 'left_menu'
  51. end
  52. def get_google_stat_year_list
  53. arr=[]
  54. start="2008_07"
  55. str=""
  56. var_date = Time.now
  57. while( start != str)
  58. var_date = var_date - 1.month
  59. str = var_date.year.to_s + "_" + "%02d" % var_date.month.to_s
  60. arr << var_date.strftime("%Y")
  61. end
  62. return arr.uniq
  63. end
  64. end