<commit_before>class GroupsController < ApplicationController
  def index
    # people/1/groups
    if params[:person_id]
      @person = Person.find(params[:person_id])
      respond_to do |format|
        format.js   { render :partial => 'person_groups' }
        format.html { render :partial => 'person_groups', :layout => true }
        if can_export?
          format.xml { render :xml =>  @person.groups.to_xml(:except => %w(site_id)) }
          format.csv { render :text => @person.groups.to_csv(:except => %w(site_id)) }
        end
      end
    # search by name or category
    elsif params[:category] or params[:name]
      conditions = []
      conditions.add_condition ['hidden = ? and approved = ?', false, true] unless @logged_in.admin?(:manage_groups)
      conditions.add_condition ['category = ?', params[:category]] if params[:category]
      conditions.add_condition ['name like ?', '%' + params[:name] + '%'] if params[:name]
      @groups = Group.find(:all, :conditions => conditions, :order => 'name')
      conditions[1] = true # only hidden groups
      @hidden_groups = Group.find(:all, :conditions => conditions, :order => 'name')
      respond_to do |format|
        format.html { render :action => 'search' }
        if can_export?
          format.xml { render :xml =>  @groups.to_xml(:except => %w(site_id)) }
          format.csv { render :text => @groups.to_csv(:except => %w(site_id)) }
        end
      end
    # regular index
    else
      @categories = Group.categories
      if @logged_in.admin?(:manage_groups)
        @unapproved_groups = Group.find_all_by_approved(false)
      else
        @unapproved_groups = Group.find_all_by_creator_id_and_approved(@logged_in.id, false)
      end
      @person = @logged_in
      respond_to do |format|
        format.html
        if can_export?
          @groups = Group.paginate(:order => 'name', :page => params[:page], :per_page => params[:per_page] || MAX_EXPORT_AT_A_TIME)
          format.xml { render :xml =>  @groups.to_xml(:except => %w(site_id)) }
          format.csv { render :text => @groups.to_csv(:except => %w(site_id)) }
        end
      end
    end
  end
    
  def show
    @group = Group.find(params[:id])
    @stream_items = @group.shared_stream_items(20)
    @show_map = Setting.get(:services, :yahoo) && @group.mapable?
    @can_post = @group.can_post?(@logged_in)
    @can_share = @group.can_share?(@logged_in)
    @member_of = @logged_in.member_of?(@group)<commit_msg>Export checkin groups to json<commit_after>class GroupsController < ApplicationController
  def index
    # people/1/groups
    if params[:person_id]
      @person = Person.find(params[:person_id])
      respond_to do |format|
        format.js   { render :partial => 'person_groups' }
        format.html { render :partial => 'person_groups', :layout => true }
        if can_export?
          format.xml { render :xml =>  @person.groups.to_xml(:except => %w(site_id)) }
          format.csv { render :text => @person.groups.to_csv(:except => %w(site_id)) }
        end
      end
    # /groups?category=Small+Groups
    # /groups?name=college
    elsif params[:category] or params[:name]
      conditions = []
      conditions.add_condition ['hidden = ? and approved = ?', false, true] unless @logged_in.admin?(:manage_groups)
      conditions.add_condition ['category = ?', params[:category]] if params[:category]
      conditions.add_condition ['name like ?', '%' + params[:name] + '%'] if params[:name]
      @groups = Group.find(:all, :conditions => conditions, :order => 'name')
      conditions[1] = true # only hidden groups
      @hidden_groups = Group.find(:all, :conditions => conditions, :order => 'name')
      respond_to do |format|
        format.html { render :action => 'search' }
        if can_export?
          format.xml { render :xml =>  @groups.to_xml(:except => %w(site_id)) }
          format.csv { render :text => @groups.to_csv(:except => %w(site_id)) }
        end
      end
    # /groups
    else
      @categories = Group.categories
      if @logged_in.admin?(:manage_groups)
        @unapproved_groups = Group.find_all_by_approved(false)
      else
        @unapproved_groups = Group.find_all_by_creator_id_and_approved(@logged_in.id, false)
      end
      @person = @logged_in
      respond_to do |format|
        format.html
        if can_export?
          format.xml do
            @groups = Group.paginate(:order => 'name', :page => params[:page], :per_page => params[:per_page] || MAX_EXPORT_AT_A_TIME)
            render :xml =>  @groups.to_xml(:except => %w(site_id))
          end
          format.csv do
            @groups = Group.paginate(:order => 'name', :page => params[:page], :per_page => params[:per_page] || MAX_EXPORT_AT_A_TIME)
            render :text => @groups.to_csv(:except => %w(site_id))
          end
          format.json do
            @groups = {}
            CheckinTime.today.each do |time|
              @groups[time.time_to_s] = time.groups.all(:order => 'group_times.ordering', :select => '*, group_times.print_nametag').map { |g| [g.id, g.name, g.print_nametag?] }
            end
            render :text => @groups.to_json
          end
        end
      end
    end
  end
    
  def show
    @group = Group.find(params[:id])
    @stream_items = @group.shared_stream_items(20)
    @show_map = Setting.get(:services, :yahoo) && @group.mapable?
    @can_post = @group.can_post?(@logged_in)
    @can_share = @group.can_share?(@logged_in)
    @member_of = @logged_in.member_of?(@group)
{'fraction_non_alphanumeric': 0.14316702819956617, 'fraction_numerical': 0.0014461315979754157, 'mean_word_length': 2.792323509252913, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 18}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4721847', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1738, 'n_words': 359}