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

Commit

Permalink
Fixed LAC team positions not scoring, team logos no longer cached and…
Browse files Browse the repository at this point in the history
… should update right away when uploaded
  • Loading branch information
nickfrerichs committed Oct 14, 2017
1 parent 8c96464 commit 65b4838
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 302 deletions.
5 changes: 2 additions & 3 deletions application/controllers/myteam/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function index()
$data = array();
$data['owner_info'] = $this->myteam_settings_model->get_owner_info();
$data['team_info'] = $this->myteam_settings_model->get_team_info();
$data['team_uploaded_logo_url'] = site_url('images/team_logos/'.$this->teamid."_uploaded_logo.jpg");
$data['team_thumb_logo_url'] = site_url('images/team_logos/'.$this->teamid."_thumb_logo.jpg");
$data['team_uploaded_logo_url'] = site_url('images/team_logos/'.$this->teamid."_uploaded_logo.jpg?nocache=".time());
$data['team_thumb_logo_url'] = site_url('images/team_logos/'.$this->teamid."_thumb_logo.jpg?nocache=".time());
$this->user_view('user/myteam/settings',$data);
}

Expand All @@ -26,7 +26,6 @@ function ajax_change_password()
$curpass = $this->input->post('curpass');
$newpass = $this->input->post('newpass');
$identity = $this->myteam_settings_model->get_owner_identity();
//echo "curpass".$curpass;
echo $this->flexi_auth_full->change_password($identity, $curpass, $newpass);

}
Expand Down
287 changes: 0 additions & 287 deletions application/controllers/season/Scores.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,291 +81,4 @@ function compact()
$this->user_view('user/season/scores/live/compact',$data);
}

// function live_scores()
// {
// if ($this->session->userdata('live_scores'))
// echo "1";
// else
// echo "0";
// //$this->load->model('security_model');

// //if ($this->security_model->live_scores_on())
// // echo "1";
// //else
// // echo "0";
// }

// function stream_live_scores_key()
// {
// session_write_close();
// header("Content-Type: text/event-stream\n\n");
// header("Cache-Control: no-cache\n\n");
// while(1)
// {
// echo "data: ".$this->scores_model->get_live_scores_key()."\n\n";
// ob_flush(); // Needed to add this after moving to centos, no idea why.
// flush();
// usleep(5000000); //5 seconds
// }
// }

// function live_json()
// {

// $data['scores'] = $this->scores_model->get_fantasy_scores_array();
// $data['players_live'] = $this->scores_model->get_player_live_array();
// $data['nfl_games'] = $this->scores_model->get_nfl_game_live_array();


// //$data['game_scores'] = $this->scores_model->get_nfl_game_scores_array();
// echo json_encode($data);

// if (1 == 0)
// {
// echo "<pre>";
// print_r($data);
// echo "</pre>";
// }

// }

// function display()
// {
// $week = $this->current_week;
// $year = $this->current_year;
// $week_type = $this->week_type;

// // Years needed to display nav bar to select statistics to display
// $years = $this->scores_model->get_scores_years();
// $week_types = $this->scores_model->get_week_types();
// $this->load->helper('form');

// if($this->input->post('week'))
// {
// $week = $this->input->post('week');
// $year = $this->input->post('year');
// }
// elseif($this->input->post('year'))
// {
// $year = $this->input->post('year');
// }

// if ($week_type == "POST")
// $schedule = $this->scores_model->get_week_schedule_data(1, $year, $this->week_type);
// else
// $schedule = $this->scores_model->get_week_schedule_data($week, $year, $this->week_type);

// if (count($schedule) == 0)
// {
// // If no schedule exist, this is the minimalist view.
// $this->user_view('user/season/scores/no_schedule',
// array('years' => $years,'week' => $week,'year' => $year, 'schedule' => $schedule, 'live' => false));
// //die();
// }
// elseif ($year >= $this->current_year && $week > $this->current_week)
// {
// echo $this->current_year;
// echo $this->session->userdata('current_year');
// // For future weeks, a much simpler display with just the schedule
// $this->user_view('user/season/scores/futureweek',
// array('years' => $years,'week' => $week,'year' => $year, 'schedule' => $schedule, 'live' => false));
// }
// else
// {
// if ($week_type == "POST") # Use total, not just for 1 week.
// $scores = $this->scores_model->get_scores_data(0, $year, "POST");
// else
// $scores = $this->scores_model->get_scores_data($week, $year, $week_type);

// $nfl_matchups = $this->scores_model->get_nfl_matchups_data($week, $year, $week_type);
// $nfl_teams = $this->scores_model->get_nfl_club_ids();

// $team_data = array();
// // Creates array of team_id's containing team data and player scores
// foreach ($scores as $score)
// {
// if (!isset($team_data[$score->team_id]['points']))
// $team_data[$score->team_id]['points'] = $score->points;
// else
// $team_data[$score->team_id]['points'] += $score->points;
// $team_data[$score->team_id]['team_name'] = $score->team_name;
// $team_data[$score->team_id]['id'] = $score->team_id;
// $team_data[$score->team_id]['players'][] =
// array('name' => $score->short_name, 'pos' => $score->pos, 'points' => $score->points,
// 'id' => $score->player_id, 'club_id' => $score->club_id, 'team_id' => $score->nfl_team_id);
// }

// $games_array = array();

// // Creates array of games containing game info with home and away team data arrays
// foreach ($schedule as $s)
// {
// if (($s->home_id == $this->teamid) || ($s->away_id == $this->teamid))
// $my_game_id = $s->game;

// if(isset($team_data[$s->home_id]))
// $games_array[$s->game]['home'] = $team_data[$s->home_id];
// else
// {
// $games_array[$s->game]['home'] = array('points' => null, 'team_name' => $s->home_name,
// 'id' => $s->home_id, 'players' => array());
// }

// if(isset($team_data[$s->away_id]))
// $games_array[$s->game]['away'] = $team_data[$s->away_id];
// else
// {
// $games_array[$s->game]['away'] = array('points' => null, 'team_name' => $s->away_name,
// 'id' => $s->away_id, 'players' => array());
// }
// $games_array[$s->game]['game_id'] = $s->game;
// }

// // If current logged in user has a team, make that the first item in the games_array.
// if (isset($my_game_id))
// {
// $my_game = $games_array[$my_game_id];
// unset($games_array[$my_game_id]);
// array_unshift($games_array, $my_game);
// }

// // Populate $gsis lookup array with byes
// $bye = 'bye';
// if ($week_type == "POST")
// $bye = 'out';

// foreach ($nfl_teams as $nfl_team)
// $gsis[$nfl_team->club_id] = array('gsis' => $bye, 'time' => '', 'match' => $bye);

// // Create lookup array for teamnames => gsis ids for live updates, also contains match text so
// // there is something to display as default for nonlive games.
// if (1==1)
// {
// foreach ($nfl_matchups as $m)
// {
// if (strtolower($m->q[0]) == "f")
// $match = $m->v.' '.$m->vs.' '.$m->h.' '.$m->hs;
// else
// $match = $m->v.'@'.$m->h;
// $gsis[$m->h] = array('gsis' => $m->gsis,'time' => $m->t,'match' => $match);
// $gsis[$m->v] = array('gsis' => $m->gsis,'time' => $m->t,'match' => $match);
// }
// }

// /*
// if ((($this->current_year == $year) && ($this->current_week == $week) && $this->scores_model->live_scores_on()) || $week_type == "POST")
// {
// if ($week_type == "POST")
// $week = $this->current_week;
// $this->user_view('user/season/scores/live',
// array('years' => $years,'week' => $week,'year' => $year,'games' => $games_array,'gsis' => $gsis,'live' => true, 'week_types' => $week_types, 'week_type' => $week_type));
// }
// */

// $this->user_view('user/season/scores/notlive',
// array('years' => $years,'week' => $week,'year' => $year,'games' => $games_array,'live' => false, 'week_types' => $week_types));

// }

// }

// function get_live_json($year = "", $week = "")
// {
// if ($year == "")
// $year = $this->current_year;
// if ($week == "")
// $week = $this->current_week;
// $week_type = $this->week_type;

// if ($week_type == 'POST')
// $player_scores = $this->scores_model->get_players_scores_data(0, $year, $week_type);
// else
// $player_scores = $this->scores_model->get_players_scores_data($week, $year, $week_type);

// $schedule = $this->scores_model->get_week_schedule_data($week, $year);
// $live_game_data = $this->scores_model->get_live_game_data($week, $year, $week_type);
// $nfl_matchups = $this->scores_model->get_nfl_matchups_data($week, $year, $week_type);

// // nfl game scores included in json to display as status when a game is completed, indexed
// // by club_id to be used as lookup table
// $gamescores = array();
// foreach($nfl_matchups as $m)
// {
// $gamescores[$m->h] = $m->v.' '.$m->vs.' '.$m->h.' '.$m->hs;
// $gamescores[$m->v] = $m->v.' '.$m->vs.' '.$m->h.' '.$m->hs;
// }


// // array of nfl games in progress and info about that game's current status
// $live_games = array();
// foreach ($live_game_data as $game)
// {
// if (strtolower($game->quarter[0]) == 'f')
// {
// $match = $game->v.' '.$game->away_score.' '.$game->h.' '.$game->home_score;
// $live_games[$game->nfl_schedule_gsis] =
// array('gametime'=>'f','off_club_id'=>$game->off_club_id,
// 'def_club_id'=>$game->def_club_id, 'match' => $match);
// continue;
// }
// if ($game->down == 1){$suffix = 'st';}
// elseif ($game->down == 2){$suffix = 'nd';}
// elseif ($game->down == 3){$suffix = 'rd';}
// elseif ($game->down == 4){$suffix = 'th';}
// else {$suffix = '';}

// if ($game->yard_line == 0){$yard_line = '50 ydln';}
// if ($game->yard_line > 0){$yard_line = $game->def_club_id.' '.(50-$game->yard_line);}
// if ($game->yard_line < 0){$yard_line = $game->off_club_id.' '.(50+$game->yard_line);}

// if ($game->yard_line > 0){$yard_line = 'opp '.(50-$game->yard_line);}
// if ($game->yard_line < 0){$yard_line = 'own '.(50+$game->yard_line);}

// if ($game->quarter == 'Halftime')
// $quarter = 'Halftime';
// else
// $quarter = $game->quarter.'Q';

// $t = explode(':',$game->time);
// $gametime = $quarter.' ('.ltrim($t[0].':'.$t[1],'0').')';
// if ($quarter == 'Halftime')
// $status = 'Halftime '.$game->off_club_id.' v '.$game->def_club_id;
// else
// $status = $gametime.' '.$game->down.$suffix.' & '.$game->to_go.' '.$yard_line;

// $details = $game->details;
// $details = substr($game->details,0,100);
// $live_games[$game->nfl_schedule_gsis] =
// //array('down'=>$game->down.$suffix,'to_go'=>$game->to_go, 'quarter'=>$game->quarter.'Q', 'note' =>$game->note,
// // 'off_club_id'=>$game->off_club_id,'def_club_id'=>$game->def_club_id,'yard_line'=>$yard_line,'time'=>$game_time);
// array('note' =>$game->note, 'status' => $status, 'details' => $details,
// 'off_club_id'=>$game->off_club_id,'def_club_id'=>$game->def_club_id,'gametime'=>$gametime);


// }

// // array of fantasy team scores (calculated), array of player fantasy points
// $teams = array();
// $players = array();

// foreach ($player_scores as $p)
// {
// $players[$p->player_id] = $p->points;
// if (!isset($teams[$p->team_id]))
// $teams[$p->team_id] = $p->points;
// else
// $teams[$p->team_id] += $p->points;
// }


// $data['live_games'] = $live_games;
// $data['game_scores'] = $gamescores;
// $data['teams'] = $teams;
// $data['players'] = $players;
// //print_r($data);

// $this->load->view('user/season/scores/get_live_json', array('data' => json_encode($data)));
// }


}
8 changes: 4 additions & 4 deletions application/models/myteam/Myteam_settings_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ function get_logo_url($teamid = '', $type = '')
//return $path.$teamid.'_uploaded_logo.jpg'

if ($type == "thumb")
return site_url($path.$teamid."_thumb_logo.jpg");
return site_url($path.$teamid."_thumb_logo.jpg?nocache=".time());
if ($type == "med")
return site_url($path.$teamid."_med_logo.jpg");
return site_url($path.$teamid."_med_logo.jpg?nocache=".time());
return site_url($path);

}
Expand All @@ -88,9 +88,9 @@ function get_default_logo_url($type = '')
{
$path = 'images/team_logos/';
if ($type = "thumb")
return site_url($path."default_thumb_logo.jpg");
return site_url($path."default_thumb_logo.jpg?nocache=".time());
if ($type = "med")
return site_url($path."med_thumb_logo.jpg");
return site_url($path."med_thumb_logo.jpg?nocache=".time());
}

function save_uploaded_logo($tempname, $filename)
Expand Down
12 changes: 6 additions & 6 deletions fflproject.sql

Large diffs are not rendered by default.

25 changes: 24 additions & 1 deletion python/db_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import MySQLdb.cursors
import config as c

CURRENT_VERSION = '1.32'
CURRENT_VERSION = '1.4'

db = MySQLdb.connect(host=c.DBHOST, user=c.DBUSER, passwd=c.DBPASS, db=c.DBNAME, cursorclass=MySQLdb.cursors.DictCursor)
cur = db.cursor()
Expand All @@ -21,6 +21,29 @@ def main():

def upgrade_db(version):

if version == "1.32":
# I never did update SD to be LAC for the team positions
cols = ['cbs_id','first_name','short_name','player_id']
query = "select id from player where player_id like '%SD%'"
cur.execute(query)
for row in cur.fetchall():
for col in cols:
query = 'update player set '+col+' = REPLACE('+col+',"SD","LAC") where id = '+str(row['id'])
cur.execute(query)

# Also delete any rows where player_id is NULL
query = 'delete from nfl_statistic where player_id is NULL'
cur.execute(query)
deleted = cur.rowcount
db.commit()
if deleted > 0:
print "Purged %s nfl_statistic rows with NULL player_ids" % (str(deleted))

query = 'update site_settings set db_version = "%s"' % ("1.4")
cur.execute(query)
db.commit()
return get_db_version()

if version == "1.31":
# Add player_id index for player_injury, player_rank, player_researchinfo, player_news
query = ('ALTER TABLE `player_injury` ADD INDEX (`player_id`)')
Expand Down
9 changes: 8 additions & 1 deletion python/livestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main():
print "Year: "+str(year)+", Week: "+str(week)+", Weektype: "+str(weektype)
print
sys.exit()

update_games(year, week, weektype, args.all)

def update_games(year, week, weektype, update_all = False):
Expand Down Expand Up @@ -325,6 +325,13 @@ def update_nfl_statistics(year, week, weektype, update_all):
db.commit()
print "Purged %s nfl_statistic rows." % str(deleted)

# Also delete any rows where player_id is NULL
query = 'delete from nfl_statistic where player_id is NULL'
cur.execute(query)
deleted = cur.rowcount
db.commit()
print "Purged %s nfl_statistic rows with NULL player_ids" % (str(deleted))

# IF live changes were made, delete nfl_live_player lines that were not updated during this run
if live_changes_made:
query = 'delete from nfl_live_player where update_key != '+str(unix_timestamp)
Expand Down

0 comments on commit 65b4838

Please sign in to comment.