diff --git a/db/90-views.sql b/db/90-views.sql index 68a01dc..d6e834e 100644 --- a/db/90-views.sql +++ b/db/90-views.sql @@ -113,3 +113,8 @@ CREATE OR REPLACE VIEW vote_score_all_vw AS UNION ALL SELECT * FROM vote_score_subscriber_vw ) AS union_vote_score GROUP BY url; + +CREATE OR REPLACE VIEW streamer_user_vw AS + SELECT users.userid as userid, users.displayname as displayname, users.imageurl as imageurl FROM streamer + LEFT JOIN users + ON streamer.userid = users.userid; diff --git a/src/app.ts b/src/app.ts index 464b0d0..47effec 100644 --- a/src/app.ts +++ b/src/app.ts @@ -233,17 +233,26 @@ app.get("/callback", async (request, response) => { // Frontend templates app.get("/", async (request, response) => { if (request.session) await validateApiToken(request.session); + const getStreamerInfoQuery = { + name: "getStreamerInfo", + text: "SELECT displayname,imageurl FROM streamer_user_vw" + } + var streamerInfo = await db.query(getStreamerInfoQuery).then((result: pg.QueryResult) => result.rows[0]);; if (!request.session || !request.session.user) { response.render('main.eta', { loggedIn: false, clientId: config.twitchClientId, - urlPrefix: config.urlPrefix + urlPrefix: config.urlPrefix, + streamerName: streamerInfo['displayname'], + streamerProfilePicture: streamerInfo['imageurl'] }); } else { response.render('main.eta', { loggedIn: true, userName: request.session.user.display_name, - userProfilePicture: request.session.user.profile_image_url + userProfilePicture: request.session.user.profile_image_url, + streamerName: streamerInfo['displayname'], + streamerProfilePicture: streamerInfo['imageurl'] }); } }); diff --git a/views/main.eta b/views/main.eta index ece0f4c..95760cb 100644 --- a/views/main.eta +++ b/views/main.eta @@ -2,13 +2,13 @@
-