Skip to content

Commit 9a1d843

Browse files
committed
merge conflicts
2 parents 2b3cd3b + 60dd051 commit 9a1d843

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+622
-2474
lines changed

.circleci/config.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
version: 2.1
22

33
orbs:
4-
hokusai: artsy/hokusai@0.3.0
4+
hokusai: artsy/hokusai@0.7.0
55

66
jobs:
77
build-and-test:
8-
docker:
9-
- image: artsy/hokusai
8+
executor: hokusai/deploy
109
steps:
1110
- add_ssh_keys
1211
- checkout
@@ -54,10 +53,5 @@ workflows:
5453
- push-staging-image
5554

5655
# Release
57-
- hokusai/push:
58-
name: push-production-image
59-
<<: *only_release
6056
- hokusai/deploy-production:
6157
<<: *only_release
62-
requires:
63-
- push-production-image

.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,5 @@ SAILTHRU_SECRET=REPLACE_ME
7272
SECURE_IMAGES_URL=REPLACE_ME
7373
FB_PAGE_ID=REPLACE_ME
7474
DEFAULT_PARTNER_ID=REPLACE_ME
75-
DISPLAY_ID=REPLACE_ME
7675
SENTRY_PUBLIC_DSN=REPLACE_ME
7776
SENTRY_PRIVATE_DSN=REPLACE_ME

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@ yarn task scripts/backfill.js
141141

142142
## Additional docs
143143

144-
You can find additional documentation about Positron in [doc](/doc).
144+
You can find additional documentation about Positron in [doc](/doc) and [data-sync](/data-sync).

data-sync/README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
## Data Sync Ops
1+
# Data Sync Ops
2+
3+
## Updating the data synchronization process
24

35
### The Short
46

@@ -75,4 +77,22 @@ Do the following:
7577
585031190124.dkr.ecr.us-east-1.amazonaws.com/positron:data-sync and can be
7678
`docker pull`-ed or referenced via Kubernetes and Hokusai.
7779

80+
## Running the data synchronization process
81+
82+
Positron is configured for daily data synchronization. [An export is scheduled from production](../hokusai/production.yml#L222), and [an import is scheduled for staging an hour later](../hokusai/staging.yml#L225).
83+
84+
If you need to run the data sync process on-demand, this can be done by pointing hokusai at the `data-sync` tag.
85+
86+
To export the data from production, run:
87+
88+
```sh
89+
hokusai production run --tag data-sync 'sh ./export-mongo.sh'
90+
```
91+
92+
This uploads the data to an S3 bucket, which can then be imported into staging:
93+
94+
```sh
95+
hokusai staging run --tag data-sync 'sh ./import-mongo.sh'
96+
```
97+
7898
[0]:https://console.aws.amazon.com/ecr/get-started?region=us-east-1

hokusai/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ git-remote: git@github.com:artsy/positron.git
22
project-name: positron
33
pre-build: export COMMIT_HASH=$(git rev-parse --short HEAD)
44
pre-deploy: yarn publish-assets
5-
hokusai-required-version: ">=0.5.3"
5+
hokusai-required-version: "~=0.5"

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"resolutions": {
2828
"babel-core": "^7.0.0-0",
2929
"babel-plugin-relay": "https://github.com/artsy/relay/releases/download/v1.5.0-artsy.5/babel-plugin-relay-1.5.0-artsy.5.tgz",
30-
"react": "16.8.3",
30+
"react": "16.8.4",
3131
"react-relay": "https://github.com/artsy/relay/releases/download/v1.5.0-artsy.5/react-relay-1.5.0-artsy.5.tgz",
3232
"react-test-renderer": "16.8.3",
3333
"relay-compiler": "https://github.com/artsy/relay/releases/download/v1.5.0-artsy.5/relay-compiler-1.5.0-artsy.5.tgz",
@@ -36,10 +36,10 @@
3636
},
3737
"dependencies": {
3838
"@artsy/bucket-assets": "1.0.3",
39-
"@artsy/express-reloadable": "1.4.6",
39+
"@artsy/express-reloadable": "1.4.7",
4040
"@artsy/gemup": "0.0.3",
41-
"@artsy/palette": "4.14.27",
42-
"@artsy/reaction": "16.18.7",
41+
"@artsy/palette": "4.17.7",
42+
"@artsy/reaction": "18.1.16",
4343
"@babel/cli": "7.0.0",
4444
"@babel/core": "7.0.0",
4545
"@babel/node": "7.0.0",
@@ -97,7 +97,7 @@
9797
"jwt-decode": "2.2.0",
9898
"kerberos": "0.0.21",
9999
"knox": "0.9.2",
100-
"lodash": "4.17.11",
100+
"lodash": "4.17.13",
101101
"lokka": "1.7.0",
102102
"lokka-transport-http": "1.6.1",
103103
"mocha": "3.2.0",
@@ -113,8 +113,8 @@
113113
"prop-types": "15.6.0",
114114
"raven": "2.0.2",
115115
"raven-js": "3.15.0",
116-
"react": "16.8.3",
117-
"react-dom": "16.8.3",
116+
"react": "16.8.4",
117+
"react-dom": "16.8.4",
118118
"react-dom-factories": "1.0.2",
119119
"react-hot-loader": "4.0.0",
120120
"react-redux": "5.0.6",

src/api/apps/graphql/index.js

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Article from "api/apps/articles/model/schema.coffee"
77
import Author from "api/apps/authors/model.coffee"
88
import Channel from "api/apps/channels/model.coffee"
99
import Curation from "api/apps/curations/model.coffee"
10-
import Display from "api/apps/graphql/schemas/display.js"
1110
import * as resolvers from "api/apps/graphql/resolvers.js"
1211
import Tag from "api/apps/tags/model.coffee"
1312
import { setUser } from "api/apps/users/routes.coffee"
@@ -42,24 +41,55 @@ const metaFields = {
4241
}),
4342
relatedArticles: array()
4443
.items(
45-
object(Article.inputSchema).concat(
46-
object({
47-
authors: array()
48-
.items(object(Author.schema))
49-
.meta({
50-
resolve: resolvers.relatedAuthors,
44+
object(Article.inputSchema)
45+
.concat(
46+
object({
47+
authors: array()
48+
.items(object(Author.schema))
49+
.meta({
50+
resolve: resolvers.relatedAuthors,
51+
}),
52+
})
53+
)
54+
.concat(
55+
object({
56+
seriesArticle: object(Article.inputSchema).meta({
57+
resolve: resolvers.seriesArticle,
5158
}),
52-
})
53-
)
59+
})
60+
)
61+
.concat(
62+
object({
63+
relatedArticles: array()
64+
.items(
65+
object(Article.inputSchema)
66+
.concat(
67+
object({
68+
authors: array()
69+
.items(object(Author.schema))
70+
.meta({
71+
resolve: resolvers.relatedAuthors,
72+
}),
73+
})
74+
)
75+
.concat(
76+
object({
77+
seriesArticle: object(Article.inputSchema).meta({
78+
resolve: resolvers.seriesArticle,
79+
}),
80+
})
81+
)
82+
)
83+
.meta({
84+
resolve: resolvers.relatedArticles,
85+
}),
86+
})
87+
)
5488
)
5589
.meta({
5690
name: "RelatedArticles",
5791
resolve: resolvers.relatedArticles,
5892
}),
59-
display: Display.schema.meta({
60-
args: Display.querySchema,
61-
resolve: resolvers.display,
62-
}),
6393
authors: array()
6494
.items(object(Author.schema))
6595
.meta({
@@ -103,10 +133,6 @@ const schema = joiql({
103133
args: Channel.querySchema,
104134
resolve: resolvers.channels,
105135
}),
106-
display: Display.schema.meta({
107-
args: Display.querySchema,
108-
resolve: resolvers.display,
109-
}),
110136
tags: array()
111137
.items(object(Tag.schema))
112138
.meta({

src/api/apps/graphql/resolvers.js

Lines changed: 22 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import _ from "underscore"
2-
import moment from "moment"
3-
import { get } from "lodash"
42
const Author = require("api/apps/authors/model.coffee")
53
const Channel = require("api/apps/channels/model.coffee")
64
const Curation = require("api/apps/curations/model.coffee")
@@ -14,9 +12,6 @@ const {
1412
find,
1513
} = require("api/apps/articles/model/index.js")
1614
const { ObjectId } = require("mongojs")
17-
const { DISPLAY_ID } = process.env
18-
19-
let DISPLAY_COUNTER = 0
2015

2116
export const articles = (root, args, req, ast) => {
2217
const unpublished = !args.published || args.scheduled
@@ -125,70 +120,38 @@ export const channels = (root, args, req, ast) => {
125120
})
126121
}
127122

128-
export const display = (root, args, req, ast) => {
129-
return new Promise((resolve, reject) => {
130-
Curation.mongoFetch(
131-
{
132-
_id: ObjectId(DISPLAY_ID),
133-
},
134-
(err, { results }) => {
135-
if (err) {
136-
reject(new Error(err))
137-
}
138-
if (!results.length) {
139-
resolve(null)
140-
}
141-
142-
const firstResultCampaigns = get(results, "0.campaigns", [])
143-
144-
// Filter for campaigns that are available based on date
145-
const now = moment(new Date())
146-
const liveCampaigns = _.filter(firstResultCampaigns, campaign => {
147-
const { start_date, end_date } = campaign
148-
149-
const startsAfterNow = moment(start_date).isAfter(now)
150-
const endsBeforeNow = moment(end_date).isBefore(now)
151-
return !(startsAfterNow || endsBeforeNow)
152-
})
153-
154-
if (liveCampaigns.length > 5) {
155-
reject(new Error("Share of voice sum cannot be greater than 100"))
156-
} else {
157-
const emptyCampaigns = _.times(5 - liveCampaigns.length, () => null)
158-
liveCampaigns.push(...emptyCampaigns)
159-
160-
const result = liveCampaigns[DISPLAY_COUNTER]
161-
162-
if (DISPLAY_COUNTER === 4) {
163-
DISPLAY_COUNTER = 0
164-
} else {
165-
DISPLAY_COUNTER = DISPLAY_COUNTER + 1
166-
}
167-
168-
resolve(result)
169-
}
170-
}
171-
)
172-
})
173-
}
174-
175-
export const relatedArticles = root => {
123+
export const relatedArticles = (root, args, req) => {
176124
const { related_article_ids } = root
125+
const relatedArticleArgs = {
126+
ids: related_article_ids,
127+
channel_id: ObjectId(root.channel_id),
128+
}
129+
const unauthorized = !User.hasChannelAccess(req.user, root.channel_id)
130+
if (unauthorized) {
131+
relatedArticleArgs.published = true
132+
}
177133

178134
return new Promise(async (resolve, reject) => {
179135
let relatedArticles = []
180136

181137
if (related_article_ids && related_article_ids.length) {
182-
const relatedArticleResults = await promisedMongoFetch({
183-
ids: root.related_article_ids,
184-
published: true,
185-
}).catch(e => reject(e))
186-
138+
relatedArticleArgs.limit = related_article_ids.length
139+
const relatedArticleResults = await promisedMongoFetch(
140+
relatedArticleArgs
141+
).catch(e => reject(e))
187142
relatedArticles = presentCollection(relatedArticleResults).results
188143
}
189144

190145
if (relatedArticles.length) {
191-
resolve(relatedArticles)
146+
const relatedArticlesById = relatedArticles.reduce(
147+
(lookupIndex, val) => ({
148+
...lookupIndex,
149+
[val.id]: val,
150+
}),
151+
{}
152+
)
153+
const output = related_article_ids.map(id => relatedArticlesById[id])
154+
resolve(output)
192155
} else {
193156
resolve(null)
194157
}
@@ -308,7 +271,6 @@ export const seriesArticle = root => {
308271
return new Promise(async (resolve, reject) => {
309272
const seriesArticles = await promisedMongoFetch({
310273
layout: "series",
311-
published: true,
312274
}).catch(e => reject(e))
313275

314276
seriesArticles.results.map(article => {

src/api/apps/graphql/schemas/display.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)