Skip to content

Commit

Permalink
Merge pull request #1218 from kanaabe/looker-fields
Browse files Browse the repository at this point in the history
@eessex => Add section types to Looker export
  • Loading branch information
eessex authored Aug 9, 2017
2 parents cedb495 + 97569ea commit fc41010
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/daily_upload_s3.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mongojs = require 'mongojs'
fs = require 'fs'
path = require 'path'
moment = require 'moment'
{ pluck, object } = require 'underscore'
{ pluck, object, pick } = require 'underscore'

# Setup environment variables
env = require 'node-env-file'
Expand Down Expand Up @@ -53,6 +53,8 @@ attrs = [
'indexable'
'is_super_article'
'description'
'sections'
'hero_section'
]
projections = object attrs, attrs.map -> 1

Expand All @@ -68,6 +70,9 @@ db.articles.find({ published: true }, projections).toArray (err, articles) ->
articles.map (a) ->
published_at = if a.published_at then moment(a.published_at).format('YYYY-MM-DDThh:mm') + "-05:00" else ''
contributing_authors = stringify(pluck(a.contributing_authors, 'name'))
sections = a.sections.map (section) => pick section, 'type'
if a.hero_section
hero = stringify(JSON.stringify(pick a.hero_section, 'type'))
row = [
a._id
a.author_id
Expand Down Expand Up @@ -97,6 +102,8 @@ db.articles.find({ published: true }, projections).toArray (err, articles) ->
a.indexable
a.is_super_article
stringify a.description
stringify(JSON.stringify(sections))
hero
].join(',')
csv.push row

Expand Down

0 comments on commit fc41010

Please sign in to comment.