Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

Commit

Permalink
Merge pull request #116 from CatalystCode/connector-query
Browse files Browse the repository at this point in the history
Stream query
  • Loading branch information
Smarker committed Aug 23, 2017
2 parents 5a08a6b + faf767a commit abd7bbf
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/resolvers-cassandra/Settings/index.js
Expand Up @@ -19,6 +19,7 @@ module.exports = {
removeBlacklist: mutations.removeBlacklist,

sites: queries.sites,
streams: queries.streams,
twitterAccounts: queries.twitterAccounts,
trustedTwitterAccounts: queries.trustedTwitterAccounts,
facebookPages: queries.facebookPages,
Expand Down
27 changes: 27 additions & 0 deletions src/resolvers-cassandra/Settings/queries.js
Expand Up @@ -49,6 +49,32 @@ function sites(args, res) { // eslint-disable-line no-unused-vars
});
}

/**
* @param {{siteId: string}} args
* @returns {Promise.<{runTime: string, sites: Array<{pipelineKey: string, pipelineLabel: string, pipelineIcon: string, streamFactory: string}>}>}
*/
function streams(args, res) { // eslint-disable-line no-unused-vars
return new Promise((resolve, reject) => {
cassandraConnector.executeQuery('SELECT * FROM fortis.streams', [])
.then(rows => {
const streams = rows.map(cassandraRowToStream);
resolve({
streams
});
})
.catch(reject);
});
}

function cassandraRowToStream(row) {
return {
pipelineKey: row.pipelinekey,
pipelineLabel: row.pipelinelabel,
pipelineIcon: row.pipelineicon,
streamFactory: row.streamfactory
};
}

function cassandraRowToTwitterAccount(row) {
return {
accountName: row.params.accountName,
Expand Down Expand Up @@ -172,6 +198,7 @@ function termBlacklist(args, res) { // eslint-disable-line no-unused-vars

module.exports = {
sites: trackEvent(withRunTime(sites), 'sites'),
streams: trackEvent(withRunTime(streams), 'streams'),
twitterAccounts: trackEvent(withRunTime(twitterAccounts), 'twitterAccounts'),
trustedTwitterAccounts: trackEvent(withRunTime(trustedTwitterAccounts), 'trustedTwitterAccounts'),
facebookPages: trackEvent(withRunTime(facebookPages), 'facebookPages'),
Expand Down
12 changes: 7 additions & 5 deletions src/schemas/SettingsSchema.js
Expand Up @@ -3,6 +3,7 @@ const graphql = require('graphql');
module.exports = graphql.buildSchema(`
type Query {
sites(siteId: String): SiteCollection
streams: StreamCollection
twitterAccounts(siteId: String!): TwitterAccountCollection
trustedTwitterAccounts(siteId: String!): TrustedTwitterAccountCollection
facebookPages(siteId: String!): FacebookPageCollection
Expand Down Expand Up @@ -50,17 +51,18 @@ module.exports = graphql.buildSchema(`
sites: [Site]!,
}
type StreamProperties {
type StreamCollection {
runTime: String,
streams: [Stream]!
}
type Stream {
pipelineKey: String,
pipelineLabel: String,
pipelineIcon: String,
streamFactory: String
}
type Stream {
properties: StreamProperties!
}
type TwitterAccountCollection {
runTime: String,
accounts: [TwitterAccount]
Expand Down

0 comments on commit abd7bbf

Please sign in to comment.