Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4623516
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:59:54+00:00 2026-05-22T02:59:54+00:00

I desperately need some help. I’ve been tasked with throwing together a utility for

  • 0

I desperately need some help. I’ve been tasked with throwing together a utility for one of our teams to use to do some basic analysis on data files. I’ve been away from coding on a daily basis for a while now, so I’m a little rusty. I’ll try to be concise in describing my problem.

Scenario: List Operations team creates data files for email marketing campaigns. Marketing campaigns are multi-segmented; each segment identified by a keycode. The total number of records averages around 450,000 and file size around 20MB.

We’re having serious junking issues right now so the marketing dept would like some basic analysis on the number of records with gmail, yahoo, and hotmail addresses by segment.

Current Status: I have a Rails 3 app created that allows the user to upload multiple files and for those records to be saved in a MySQL database.

Here’s a very basic sample of what the database records would look like, not including standard fields like id and the timestamps:

domain       eid    keycode  
YAHOO.COM    42886  GY4103  
HOTMAIL.COM  53012  GY4103  
YAHOO.COM    53952  GY4103  
AOL.COM      54327  GY4103  
COMCAST.NET  55134  MX4155  
GMAIL.COM    59157  MX4155  
AOL.COM      59823  MX4155  
AOL.COM      60384  MX4161  
MSN.COM      64720  MX4161  
YAHOO.COM    67790  MX4161
GMAIL.COM    73537  MX4161
YAHOO.COM    76747  MX4161  
HOTMAIL.COM  71467  MX4161
GMAIL.COM    84280  MX4161  

Problem: I need to present the analysis to the end user as:

Keycode
GY4103
  Domain       Count
  YAHOO.COM    2
  HOTMAIL.COM  1
  OTHER        1
MX4155
  Domain       Count
  GMAIL.COM    1
  OTHER        2
MX4161
  Domain       Count
  YAHOO.COM    2
  HOTMAIL.COM  1
  GMAIL.COM    2
  OTHER        2

If I were in something like Crystal Reports, I would just group by the keycode, then by domain, and then a count of the eid’s under that, do some tweaking to show only the 3 domains I want and everything else as “other” and I’m done! However, using CR isn’t possible here.

So I’m assuming I’m after creating some type of tree structure or hierarchy with Keycode at the top level, then domain under that, and a count under that?? I started taking a look at the Ancestry gem, but I’m not really getting it.

Any help that anyone could provide would be much appreciated, especially considering I need to deliver this by noon tomorrow.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:59:54+00:00Added an answer on May 22, 2026 at 2:59 am

    I would probably mix in a little manual SQL in this since it seems to be such a large dataset to handle. Perhaps something like this:

    # CONTROLLER
    # Load the data from the database and group on keycode and domain.
    # You will only get one record for each unique combination of domain and keycode
    @records = MyModel.select("keycode, domain, COUNT(eid) AS eids").group("keycode, domain")
    
    # convert the array of records into a hash where every key is a unique keycode
    # and the value is an array of records for all the domains for that keycode
    @records = @records.group_by(&:keycode)
    
    # VIEW
    <% @records.keys.each do |keycode| %>
      <h1><%= keycode %></h1>
      <% @records[keycode].each do |record| %>
        <p><%= record.domain %>: <%= record.eids %></p>
      <% end %>
    <% end %>
    

    I hope I understood everything correctly

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I desperately need some help on this one. I've created a <script> that closely
I am new in this field and i desperately need some guidance from u
I desperately need to be able to get some information from the request array
I am in desperate need for some algorithm help when combining lists inside lists.
I'm new to this ExpandableListView and I desperately need your help please. I'm using
I am desperately in need of advice. I am attempting to mask some textboxes
Long story short, client's hosting is using php 5.2.5 and i desperately need to
I am in desperate need of help, I need to manage an application dependency
I've been trying desperately to get my application (15 C# dlls and 1 C++/CLI
I'm desperately searching for the keystroke to access a help menu from my Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.