Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
working stream url
Browse files Browse the repository at this point in the history
  • Loading branch information
James Baxley committed Jul 12, 2016
1 parent 927ce00 commit c810c08
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
22 changes: 21 additions & 1 deletion src/expression-engine/models/content/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import {
TagEntries,
} from "../ee/tags";

import {
Snippets,
} from "../ee/snippets";

import { EE } from "../ee";

export interface ChannelField {
Expand Down Expand Up @@ -192,7 +196,23 @@ export class Content extends EE {
;
}

public async getLiveStream(/* site: string */): Promise<any> {
public async getLiveStream(): Promise<any> {
return this.getIsLive()
.then(({ isLive }) => {
if (!isLive) return { isLive, snippet_contents: null };

return this.getStreamUrl()
.then(({ snippet_contents }) => ({isLive, snippet_contents}));
});
}

private async getStreamUrl(): Promise<any> {
return this.cache.get("snippets:PUBLIC_EMBED_CODE", () => Snippets.findOne({
where: { snippet_name: "PUBLIC_EMBED_CODE" },
}));
}

private async getIsLive(): Promise<any> {
// tslint:disable
return this.cache.get("newspring:live", () => ChannelData.db.query(`
SELECT
Expand Down
3 changes: 1 addition & 2 deletions src/expression-engine/models/content/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ export default {
},

live(_, $, { models }) {
// XXX pass in site
return models.Content.getLiveStream();
},
},

LiveFeed: {
live: ({ isLive }) => !!isLive,
streamUrl: (data) => "Hello World",
streamUrl: ({ snippet_contents }) => snippet_contents,
},

ContentColor: {
Expand Down
42 changes: 42 additions & 0 deletions src/expression-engine/models/ee/snippets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* tslint:disable:no-shadowed-variable */

import {
INTEGER,
STRING,
} from "sequelize";

import { MySQLConnector, Tables } from "../../mysql";

const snippetsSchema: Object = {
snippet_id: { type: INTEGER, primaryKey: true },
site_id: { type: STRING },
snippet_name: { type: STRING },
snippet_contents: { type: STRING },
};

let Snippets;
export {
Snippets,
snippetsSchema,
};

export function connect(): Tables {
Snippets = new MySQLConnector("exp_snippets", snippetsSchema);

return {
Snippets,
};
};

// export function bind({
// ChannelData,
// Sites,
// }: Tables): void {


// };

export default {
connect,
// bind,
};
2 changes: 2 additions & 0 deletions src/expression-engine/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import matrix from "./ee/matrix";
import playa from "./ee/playa";
import tags from "./ee/tags";
import sites from "./ee/sites";
import snippets from "./ee/snippets";
import navee from "./../models/navigation/tables";

let tables = {
Expand All @@ -18,6 +19,7 @@ let tables = {
sites,
tags,
navee,
snippets,
} as {
[key: string]: {
connect: () => Tables;
Expand Down

0 comments on commit c810c08

Please sign in to comment.