Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into new-ep-stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Wright committed Aug 7, 2017
2 parents e97789f + 6d1a15b commit 16a6ce7
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ public/bundle.css
*.sublime-workspace
playground/*
*.log
this_season.txt

2 changes: 1 addition & 1 deletion app/components/EpisodeList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class EpisodeList extends React.Component {
</div>
{renderEpisode()}

{ renderDisqus }
{ process.env.NODE_ENV !== 'development' ? renderDisqus : '' }


</div>
Expand Down
16 changes: 8 additions & 8 deletions app/components/Leaderboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ export class Leaderboard extends React.Component {

return leaders.sort(sortObjectsByKey(key, reverse)).map(
leader => (
<LeaderboardEntry {...leader}
userId={leader.key}
value={leader[key]}
index={i++}
profileUser={leader.key === userId}
authUser={leader.key === authUserId}
renderKey={key}
season={season}
<LeaderboardEntry { ...leader }
userId={ leader.key }
value={ leader[key] }
index={ i++ }
profileUser={ leader.key === userId }
authUser={ leader.key === authUserId }
renderKey={ key }
season={ season }
/>
)
);
Expand Down
3 changes: 2 additions & 1 deletion app/components/Score.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export function Score(props) {
function mapStateToProps(state, props) {
const { seasonId } = props;
const { login: { uid } } = state;
const userScore = getKey(state.leaderboard, `${seasonId}.${uid}`, {});
let userScore = getKey(state.leaderboard, `${seasonId}.${uid}`, {});
userScore.key = uid;

return {
authUserId: uid,
Expand Down
4 changes: 2 additions & 2 deletions app/constants/strings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export const LABEL_PREVIEW_URI = 'URL to video preview:';
export const LABEL_CONFIRMATION_URI = 'URL to results confirmation article (All Men Must Die feature):';
export const LABEL_AIR_AT = 'Airs at (RFC3339 Datetime):';
export const LABEL_LOCK_AT = 'Lock all betting at (RFC3339 Datetime):';
export const LABEL_BET_ODDS_PAYOUT = <span>Odds Payout (e.g. <strong><em>3</em></strong> : 1):</span>;
export const LABEL_BET_ODDS_WAGER = <span>Wager (e.g. 3 : <strong><em>1</em></strong>):</span>;
export const LABEL_BET_ODDS_PAYOUT = 'Odds Payout:';
export const LABEL_BET_ODDS_WAGER = 'Wager:';
export const LABEL_BET_ORDER = 'Order in the list of bets:';
export const LABEL_BET_NAME = 'Description of terms:';
export const LABEL_BET_DESCRIPTION = 'Additional info (usually specific character names for group bets):';
Expand Down
24 changes: 14 additions & 10 deletions scripts/generate-email-lists.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/
const PAST_SEASON = 'gameofthrones-06';
const CURRENT_SEASON = 'gameofthrones-07';
const SEASON_EPISODES = ['gameofthrones-07-01', 'gameofthrones-07-02'];
const CURRENT_EPISODE = 'gameofthrones-07-03';
const SEASON_EPISODES = ['gameofthrones-07-01', 'gameofthrones-07-02', 'gameofthrones-07-03'];
const CURRENT_EPISODE = 'gameofthrones-07-04';

import fs from 'fs';
import firebaseApp from './firebase-app';
Expand Down Expand Up @@ -53,23 +53,26 @@ function generateEmailLists(users, secure, bets) {

const seasonsArr = Object.keys(seasons);

wageredLastSeason = seasonsArr.includes(PAST_SEASON) && !seasonsArr.includes(CURRENT_SEASON);
// wageredLastSeason = seasonsArr.includes(PAST_SEASON) && !seasonsArr.includes(CURRENT_SEASON);
// Don't recalculate last season emails.
wageredLastSeason = false;
wageredThisSeason = !episodes[CURRENT_EPISODE] && SEASON_EPISODES.reduce((result, item) => episodes[item] || result, false);

console.log(seasons)
console.log('last season:', wageredLastSeason)
// console.log(seasons)
// console.log('last season:', wageredLastSeason)
console.log(episodes)
console.log('this season:', wageredThisSeason)

if (wageredThisSeason) {
emails_this_season.push(email);
} else if (wageredLastSeason) {
emails_last_season.push(email);
}
// } else if (wageredLastSeason) {
// emails_last_season.push(email);
// }
}
}

const emails_last_season_str = emails_last_season.sort().reduce((str, item) => { return str + item + '\n'}, '');
// const emails_last_season_str = emails_last_season.sort().reduce((str, item) => { return str + item + '\n'}, '');
const emails_this_season_str = emails_this_season.sort().reduce((str, item) => { return str + item + '\n'}, '');


Expand All @@ -78,8 +81,9 @@ function generateEmailLists(users, secure, bets) {
fs.writeFile('this_season.txt', emails_this_season_str, err);
}

fs.writeFile('last_season.txt', emails_last_season_str, writeThisSeason);
console.log('EMAILS FROM LAST YEAR', emails_last_season.length)
writeThisSeason(false);
// fs.writeFile('last_season.txt', emails_last_season_str, writeThisSeason);
// console.log('EMAILS FROM LAST YEAR', emails_last_season.length)
console.log('EMAILS FROM THIS YEAR', emails_this_season.length);
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/reset-balances.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ db.ref('bets').once('value').then(snapshot => {

// ... is not Marah Eakin
if (id.indexOf('avclub') === -1 && id !== '0yomzuaZZRVJ1c4gzbL5M1ICWyf1') {
const newBalance = curBalance + 200;
const newBalance = curBalance + 200 < 200 ? 200 : curBalance + 200;
console.log(`Updating ${id} (${displayName}, old balance ${curBalance}, locked up ${locked_up}, new balance ${newBalance}.)`);
updateData[`users/${id}/balance/${seasonId}`] = newBalance;
count++;
Expand Down
5 changes: 4 additions & 1 deletion scripts/update.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import firebaseApp from './firebase-app';

const updateData = {

['users/Jr9wO5CW1uX2li5HLFepQL9w5bn2']: true,
['secure/Jr9wO5CW1uX2li5HLFepQL9w5bn2']: true,
['roles/datamanagers/Jr9wO5CW1uX2li5HLFepQL9w5bn2']: true,
['roles/usermanagers/Jr9wO5CW1uX2li5HLFepQL9w5bn2']: true
};

console.log('Updating Firebase database', process.env.FIREBASE_DATABASE_URL);
Expand Down
8 changes: 4 additions & 4 deletions scripts/user-health-stats.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ function generateStats(users, secure) {

console.log('Watching season', CURRENT_SEASON);

secureRef.on('value', (snapshot) => {
secure = snapshot.val();
userRef.once('value').then((snapshot) => {
users = snapshot.val();
userRef.on('value', (snapshot) => {
users = snapshot.val();
secureRef.once('value').then((snapshot) => {
secure = snapshot.val();
try {
generateStats(users, secure);
} catch (err) {
Expand Down

0 comments on commit 16a6ce7

Please sign in to comment.