Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code for generating discount code report #19899

Merged
merged 2 commits into from
Jan 11, 2018
Merged

Conversation

Bjvanminnen
Copy link
Contributor

@Bjvanminnen Bjvanminnen commented Jan 10, 2018

A simple script that can be used to generate a report on the current state of our discount codes. Not 100% sure bin/oneoff is the right place for this, but not really sure of a better place either.

After pasting to google sheets, it looks something like this
image

If this were a higher volume feature, it could make sense to actually build a report view for the web, but I think given that we're expecting <1000 codes to be used, one off is probably ok.

app.school_id,
].join(',')
end
puts rows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just experimenting: I think you can do this using the CSV module's shortcut interface, but I'm not sure it's actually any better:

def discount_code_reporting
  CSV do |csv|
    csv << [
      # Column names
    ]
    CircuitPlaygroundDiscountApplication.all.each do |app|
      csv << [
        # columns for row
      ]
    end
  end
end

# It will print out a bunch of rows, one per line. You can then copy paste this
# into google sheets. After pasting, click on the little icon that shows up and
# select "Split text into columns"
def discount_code_reporting(filepath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused filepath argument?

@Bjvanminnen
Copy link
Contributor Author

I had actually originally written this doing CSV. However, because it's being run on production-console, getting the file off of the machine and into google sheets becomes a bit of a pain. It felt easier to be able to just copy/paste from the console.

@islemaster
Copy link
Contributor

The 'shortcut interface' I used there prints to stdout by default, so should be functionally equivalent to what you wrote. Of course, what you've got works perfectly well and has fewer dependencies. 😁

@Bjvanminnen Bjvanminnen merged commit 113040c into staging Jan 11, 2018
@Bjvanminnen Bjvanminnen deleted the discountCodeReporting branch January 11, 2018 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants