Skip to content

Commit

Permalink
Switch to new schema (#5)
Browse files Browse the repository at this point in the history
v3.0.0 - update schemas
Co-authored-by: Oleg Proskurin <[email protected]>
  • Loading branch information
AlexHramovich authored Nov 20, 2020
1 parent 83c2185 commit 661c5e2
Show file tree
Hide file tree
Showing 49 changed files with 19,446 additions and 2,009 deletions.
2 changes: 0 additions & 2 deletions .env

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ package-lock.json
content-log.json

dist/

.env
.env.local
36 changes: 36 additions & 0 deletions develop/conference-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const fallback = require('./fallback-settings');

const confCodes = [
'jsn',
'gqconf',
'mlconf',
'qaconf',
'doconf',
'nodeconf',
'rs',
];

const getSettings = () => {
const settings = confCodes.reduce(
(acc, code) => ({ ...acc, [code]: fallback }),
{},
);
try {
confCodes.forEach(code => {
settings[
code
] = require(`../../live-conferences/src/conferences/${code}/conference-settings`);
});
return settings;
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
console.log(
`\n\nCan't find live-conferences folder. Fallback settings will be used!\n\n`,
);
return settings;
}
throw err;
}
};

module.exports = { getSettings };
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const conferenceTitle = 'React_Summit_Online';
const conferenceTitle = 'React_Amsterdam';
const eventYear = 'Y2020';

const tagColors = {
Expand Down Expand Up @@ -34,6 +34,26 @@ const tagColors = {
tagBG: '#61DAFB',
color: '#030303',
},
'Summit Track': {
tagBG: '#a4ff00',
color: '#324e00',
},
'Base Camp Track': {
tagBG: '#696969',
color: '#e7e7e7',
},
'Lightning Talk': {
tagBG: '#2acadd',
color: '#003238',
},
'Panel Discussion': {
tagBG: '#ddce2a',
color: '#3f3a00',
},
Workshop: {
tagBG: '#bd2add',
color: '#f3cbff',
},
default: {
tagBG: 'black',
color: 'white',
Expand All @@ -48,8 +68,8 @@ const speakerAvatar = {
};

module.exports = {
conferenceTitle,
eventYear,
tagColors,
speakerAvatar,
conferenceTitle,
eventYear,
};
20 changes: 20 additions & 0 deletions develop/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const fs = require('fs');
const path = require('path');

const { getContent } = require('../dist');
const { getSettings } = require('./conference-settings');

const CURRENT_CONF = 'mlconf';

const testLaunch = async () => {
const settings = getSettings();
const content = await getContent(settings[CURRENT_CONF]);

fs.writeFileSync(
path.resolve(__dirname, '../content-log.json'),
JSON.stringify(content, null, 2),
);
// console.log('content', content);
};

testLaunch();
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"name": "@focus-reactive/graphql-content-layer",
"version": "2.3.7",
"version": "3.0.0",
"private": false,
"main": "dist/index.js",
"scripts": {
"start": "yarn dev | yarn storybook | yarn tdd",
"dev": "nodemon --exec yarn prepare",
"test-run": "node develop",
"storybook": "start-storybook -p 6001 --ci",
"update-schema": "graphql get-schema",
"test": "jest",
"test:smoke": "jest tests/smoke.test.js --detectOpenHandles",
"tdd": "jest --watch",
"prepare": "package-prepare",
"prepare": "package-prepare && yarn test-run",
"prestart": "relative-deps",
"-prepare": "yarn relative-deps",
"update-dependencies": "yarn upgradeInteractive --latest"
Expand Down Expand Up @@ -41,6 +42,7 @@
"graphql-cli": "^3.0.14",
"jest": "^24.9.0",
"nodemon": "^2.0.2",
"object-hash": "^2.0.3",
"prettier": "^1.19.1",
"relative-deps": "^0.2.0"
},
Expand All @@ -54,7 +56,7 @@
"@storybook/addons": "^5.2.8",
"@storybook/react": "^5.2.8",
"@storybook/storybook-deployer": "^2.8.1",
"dayjs": "^1.8.19",
"dayjs": "^1.9.6",
"graphql-request": "^1.8.2",
"react": "^16.12.0",
"react-json-view": "^1.19.1",
Expand Down
12 changes: 11 additions & 1 deletion src/content-type-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@ const contentTypeMap = {
PieceOfText: 'c04bfcdd2eed47b880588f5506ed4f5a',
Speaker: 'e981e312fd6c48a39230de9193be4db9',
Sponsor: 'f188bcf25c8e419d9f8d10b0926dd825',
Talk: 'd5d4bfeb605c41569b30d478a03bbb0e',
// Talk: 'd5d4bfeb605c41569b30d478a03bbb0e',
Track: '76d236bfe3344d0990028c5f69c69079',
Workshop: '2ce17eb4016e4be5ae72bb0db484f3f0',

// updated
OrgEvent: 'cda52433c9fd4a6a818f71acd217e91d',
Talk: '03b4712293184731b7d1bf074302f8e0',
QA: '3473d8bc2712475c89e0b47d31b2ee97',
LightningTalk: '09be1744ee4d465ea3f5a82972d2cb28',
GroupLT: '694d3ca13ab44d45810c18fb01580c92',
SpeakersRoom: 'b701d52be9d84599a3d46972acafc42f',
DiscussionRoom: '07f1cfefde1942fbb63704917cbf2398',

};

module.exports = {
Expand Down
91 changes: 39 additions & 52 deletions src/fetch-advisers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { prepareSpeakers, trySelectSettings } = require('./utils');
const { trySelectSettings } = require('./utils');
const { personFragment } = require('./fragments');

const selectSettings = trySelectSettings(
Expand All @@ -23,21 +23,14 @@ const queryPages = /* GraphQL */ `
) {
conf: conferenceBrand(where: { title: $conferenceTitle }) {
id
status
year: conferenceEvents(where: { year: $eventYear }) {
year: conferenceEvents(
where: { year: $eventYear, adviceLounges_some: {} }
) {
id
status
schedule: daySchedules(where: { adviceLounges_some: {} }) {
id
status
additionalEvents
adviceLounges {
status
id
expertise
speaker {
...person
}
schedule: adviceLounges {
expertise
speaker {
...person
}
}
}
Expand All @@ -49,44 +42,38 @@ const queryPages = /* GraphQL */ `
const fetchData = async (client, { tagColors, labelColors, ...vars }) => {
const data = await client
.request(queryPages, vars)
.then(res => res.conf.year[0].schedule);
.then(res => (res.conf.year[0] ? res.conf.year[0].schedule : []));

const advisers = data.reduce(
(all, day) => [
...all,
...day.adviceLounges
.map(({ expertise, speaker }) => ({
expertise,
speaker: speaker || {},
}))
.map(
({
expertise,
speaker: {
name,
company,
bio,
githubUrl,
twitterUrl,
mediumUrl,
ownSite,
avatar,
},
}) => ({
expertise,
name,
photo: avatar && avatar.url,
company,
desc: bio,
github: githubUrl,
twitter: twitterUrl,
medium: mediumUrl,
site: ownSite,
}),
),
],
[],
);
const advisers = data
.map(({ expertise, speaker }) => ({
expertise,
speaker: speaker || {},
}))
.map(
({
expertise,
speaker: {
name,
company,
bio,
githubUrl,
twitterUrl,
mediumUrl,
ownSite,
avatar,
},
}) => ({
expertise,
name,
photo: avatar && avatar.url,
company,
desc: bio,
github: githubUrl,
twitter: twitterUrl,
medium: mediumUrl,
site: ownSite,
}),
);

return {
speakers: { advisers },
Expand Down
1 change: 0 additions & 1 deletion src/fetch-brand.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const queryPages = /* GraphQL */ `
query($conferenceTitle: ConferenceTitle) {
conf: conferenceBrand(where: { title: $conferenceTitle }) {
id
status
city
url
title
Expand Down
3 changes: 0 additions & 3 deletions src/fetch-committee.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const {
prepareSpeakers,
trySelectSettings,
contentTypeMap,
} = require('./utils');
const { personFragment } = require('./fragments');

Expand All @@ -19,10 +18,8 @@ const queryPages = /* GraphQL */ `
) {
conf: conferenceBrand(where: { title: $conferenceTitle }) {
id
status
year: conferenceEvents(where: { year: $eventYear }) {
id
status
committee {
...person
}
Expand Down
3 changes: 0 additions & 3 deletions src/fetch-diversity.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ const queryPages = /* GraphQL */ `
query($conferenceTitle: ConferenceTitle, $eventYear: EventYear) {
conf: conferenceBrand(where: { title: $conferenceTitle }) {
id
status
year: conferenceEvents(where: { year: $eventYear }) {
id
status
diversity {
id
status
title
description
maxTickets
Expand Down
2 changes: 0 additions & 2 deletions src/fetch-extended.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ const queryPages = /* GraphQL */ `
query($conferenceTitle: ConferenceTitle, $eventYear: EventYear) {
conf: conferenceBrand(where: { title: $conferenceTitle }) {
id
status
year: conferenceEvents(where: { year: $eventYear }) {
id
status
extendeds {
id
key
Expand Down
2 changes: 0 additions & 2 deletions src/fetch-faq.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ const queryPages = /* GraphQL */ `
query($conferenceTitle: ConferenceTitle, $eventYear: EventYear) {
conf: conferenceBrand(where: { title: $conferenceTitle }) {
id
status
year: conferenceEvents(where: { year: $eventYear }) {
id
status
faqs {
id
category
Expand Down
2 changes: 0 additions & 2 deletions src/fetch-jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ const queryPages = /* GraphQL */ `
query($conferenceTitle: ConferenceTitle, $eventYear: EventYear) {
conf: conferenceBrand(where: { title: $conferenceTitle }) {
id
status
year: conferenceEvents(where: { year: $eventYear }) {
id
status
jobAds {
id
title
Expand Down
4 changes: 1 addition & 3 deletions src/fetch-mc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { prepareSpeakers, trySelectSettings, contentTypeMap } = require('./utils');
const { prepareSpeakers, trySelectSettings } = require('./utils');
const { personFragment } = require('./fragments');

const selectSettings = trySelectSettings(s => s.speakerAvatar.dimensions, {
Expand All @@ -15,10 +15,8 @@ const queryPages = /* GraphQL */ `
) {
conf: conferenceBrand(where: { title: $conferenceTitle }) {
id
status
year: conferenceEvents(where: { year: $eventYear }) {
id
status
mcs {
id
speaker {
Expand Down
Loading

0 comments on commit 661c5e2

Please sign in to comment.