This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

seperate vacbans and gamebans. only send notifications on vac/game ba…

…ns. display only vac/game bans on the list and only display trade/community bans on profiles
  • Loading branch information...
jung35 committed Aug 14, 2015
1 parent c9d92b2 commit f80cf44f9ff72e1eaa8a24c010d701a6a75100e9
@@ -63,7 +63,7 @@ public function fire()
else $message .= (count($profiles) > 1 ? "and " : "") . $profile->display_name;
}
$message .= (count($profiles) > 1 ? " were " : " was")." Trade, Community, and/or VAC banned from your lists";
$message .= (count($profiles) > 1 ? " were " : " was")." VAC banned or Game banned from your lists";
$pushbullet->user($email)->note("Bans were found from your subscribed lists!", $message);
});
@@ -28,32 +28,36 @@ public function fire()
if(!Cache::has($cacheName)) return;
$smallIds = Cache::pull($cacheName);
foreach(array_chunk($smallIds, 100) as $chunkedSmallIds)
{
$profiles = Profile::whereIn('small_id', $smallIds)->get();
$profiles = Profile::whereIn('small_id', $chunkedSmallIds)->get();
foreach($profiles as $profile)
{
$steamAPI = new SteamAPI($profile->small_id, true);
$steamAlias = $steamAPI->fetch('alias');
foreach($profiles as $profile)
{
$steamAPI = new SteamAPI($profile->small_id, true);
$steamAlias = $steamAPI->fetch('alias');
if(!isset($steamAlias['error'])) usort($steamAlias, array('VacStatus\Steam\Steam', 'aliasSort'));
else $steamAlias = [];
if(!isset($steamAlias['error'])) usort($steamAlias, array('VacStatus\Steam\Steam', 'aliasSort'));
else $steamAlias = [];
$profile->alias = json_encode($steamAlias);
$profile->save();
$profile->alias = json_encode($steamAlias);
$profile->save();
$cacheName = "profile_{$profile->small_id}";
$cacheName = "profile_{$profile->small_id}";
if(!Cache::has($cacheName)) continue;
$profileCache = Cache::get($cacheName);
$profileCache['alias'] = Steam::friendlyAlias($steamAlias);
if(!Cache::has($cacheName)) continue;
$profileCache = Cache::get($cacheName);
$profileCache['alias'] = Steam::friendlyAlias($steamAlias);
if(Cache::has($cacheName)) Cache::forget($cacheName);
if(Cache::has($cacheName)) Cache::forget($cacheName);
$expireTime = Carbon::now()->addMinutes(60);
$expireTime = Carbon::now()->addMinutes(60);
Cache::put($cacheName, $profileCache, $expireTime);
Cache::put($cacheName, $profileCache, $expireTime);
}
}
}
@@ -7,7 +7,9 @@
use VacStatus\Update\MostTracked;
use VacStatus\Update\LatestTracked;
use VacStatus\Update\CustomList;
use VacStatus\Update\LatestVAC;
use VacStatus\Update\LatestGameBan;
use VacStatus\Models\User;
use VacStatus\Models\UserList;
@@ -180,6 +182,18 @@ public function latestVAC()
return $return;
}
public function latestGameBan()
{
$latestGameBan = new LatestGameBan();
$return = [
'list_info' => [ 'title' => 'Latest Game Banned Users' ],
'profiles' => $latestGameBan->getLatestGameBan()
];
return $return;
}
public function customList(UserList $userList)
{
if(!isset($userList->id)) {
@@ -61,8 +61,9 @@ public function search($searchKey)
'profile.small_id',
'profile.created_at',
'profile_ban.vac',
'profile_ban.vac_banned_on',
'profile_ban.vac_bans',
'profile_ban.game_bans',
'profile_ban.last_ban_date',
'profile_ban.community',
'profile_ban.trade',
@@ -96,16 +97,17 @@ public function search($searchKey)
continue;
}
$vacBanDate = new DateTime($profile->vac_banned_on);
$lastBanDate = new DateTime($profile->last_ban_date);
$profilesParsed[] = [
'id' => $profile->id,
'display_name' => $profile->display_name,
'avatar_thumb' => $profile->avatar_thumb,
'small_id' => (int) $smallId,
'steam_64_bit' => Steam::to64Bit($profile->small_id),
'vac' => $profile->vac,
'vac_banned_on' => $vacBanDate->format("M j Y"),
'vac_bans' => $profile->vac_bans,
'game_bans' => $profile->game_bans,
'last_ban_date' => $lastBanDate->format("M j Y"),
'community' => $profile->community,
'trade' => $profile->trade,
'site_admin' => (int) $profile->site_admin?:0,
@@ -61,6 +61,12 @@ public function latestVACPage()
->withGrab('latest_vac');
}
public function latestGameBanPage()
{
return view('pages/list')
->withGrab('latest_game_ban');
}
public function customListPage($listId)
{
return view('pages/list')
View
@@ -40,10 +40,15 @@
]);
get('/list/latest/vac', [
'as' => 'tracked.latest_vac',
'as' => 'tracked.latest.vac',
'uses' => 'PagesController@latestVACPage'
]);
get('/list/latest/game', [
'as' => 'tracked.latest.game',
'uses' => 'PagesController@latestGameBanPage'
]);
get('/list/{listId}', [
'as' => 'tracked.custom',
'uses' => 'PagesController@customListPage'
@@ -142,10 +147,15 @@
]);
get('/latest_vac', [
'as' => 'api.v1.tracked.latest_vac',
'as' => 'api.v1.tracked.latest.vac',
'uses' => 'ListController@latestVAC'
]);
get('/latest_game_ban', [
'as' => 'api.v1.tracked.latest.game',
'uses' => 'ListController@latestGameBan'
]);
get('/{userList}', [
'as' => 'api.v1.tracked.latest',
'uses' => 'ListController@customList'
View
@@ -8,8 +8,6 @@ class Profile extends Model
protected $fillable = ['small_id'];
protected $dates = ['vac_banned_on'];
public function ProfileOldAlias()
{
return $this->hasMany('VacStatus\Models\ProfileOldAlias');
View
@@ -11,18 +11,18 @@ class ProfileBan extends Model
protected $fillable = ['profile_id'];
protected $dates = ['vac_banned_on'];
protected $dates = ['last_ban_date'];
public $timestamps = true;
public $timestamps = true;
public function Profile()
{
return $this->belongsTo('VacStatus\Models\Profile', 'profile_id', 'id');
}
public function isVacBanned()
public function isVacGameBanned()
{
return $this->vac > 0;
return $this->vac_bans > 0 || $this->game_bans > 0;
}
public function isCommunityBanned()
@@ -35,33 +35,19 @@ public function isTradeBanned()
return $this->trade;
}
public function getVac()
public function getVacBans()
{
return $this->vac;
return $this->vac_bans;
}
public function getVacDays()
{
$date = new DateTime($this->vac_banned_on);
return $this->isVacBanned() ? $date->format('M j Y') : 'None';
}
public function isUnbanned()
public function getGameBans()
{
return $this->unban;
return $this->game_bans;
}
public function skipProfileBanUpdate($steamBan)
public function getVacDays()
{
$combinedBan = (int) $steamBan['NumberOfVACBans'] + (int) $steamBan['NumberOfGameBans'];
if($this->vac != $combinedBan ||
$this->community != $steamBan['CommunityBanned'] ||
$this->trade != ($steamBan['EconomyBan'] != 'none'))
{
return false;
}
return true;
$date = new DateTime($this->last_ban_date);
return $this->isVacBanned() ? $date->format('M j Y') : 'None';
}
}
View
@@ -92,8 +92,9 @@ public function getCustomList()
'profile.avatar_thumb',
'profile.small_id',
'profile_ban.vac',
'profile_ban.vac_banned_on',
'profile_ban.vac_bans',
'profile_ban.game_bans',
'profile_ban.last_ban_date',
'profile_ban.community',
'profile_ban.trade',
@@ -138,16 +139,17 @@ public function getCustomList()
foreach($userListProfiles as $userListProfile)
{
if(is_null($userListProfile->id)) continue;
$vacBanDate = new DateTime($userListProfile->vac_banned_on);
$lastBanDate = new DateTime($userListProfile->last_ban_date);
$return['profiles'][] = [
'id' => $userListProfile->id,
'display_name' => $userListProfile->profile_name?:$userListProfile->display_name,
'avatar_thumb' => $userListProfile->avatar_thumb,
'small_id' => $userListProfile->small_id,
'steam_64_bit' => Steam::to64Bit($userListProfile->small_id),
'vac' => $userListProfile->vac,
'vac_banned_on' => $vacBanDate->format("M j Y"),
'vac_bans' => $userListProfile->vac_bans,
'game_bans' => $userListProfile->game_bans,
'last_ban_date' => $lastBanDate->format("M j Y"),
'community' => $userListProfile->community,
'trade' => $userListProfile->trade,
'site_admin' => (int) $userListProfile->site_admin?:0,
@@ -11,48 +11,6 @@
use VacStatus\Steam\Steam;
/*
STEPS TO GET LATEST TRACKED USERS
*************************************************************************************************
-> Grab 20 rows from the 'user_list_profile' table
-> Order By DESC
-> The '20' is some nice number I came up with. It could be always changed around
*/
/*
RETURN FORMAT
*************************************************************************************************
return [
[ (There should be many of these) (SORTED BY DESC) (NO SPECIFIC INDEX VALUE)
profile.id
profile.display_name
profile.avatar_thumb
profile_ban.vac
-> this is the number of vac bans
profile_ban.vac_banned_on
-> see to convert date
https://github.com/jung3o/VacStatus/tree/c6e626d8f8ab5f8c99db80f904275c185698c645/app/models/Profile.php#L131
profile_ban.community
profile_ban.trade
users.site_admin
-> color name (class: .admin-name)
users.donation
-> color name (class: .donator-name)
users.beta
-> color name (class: .beta-name)
]
]
*/
class LatestTracked extends BaseUpdate
{
function __construct()
@@ -87,8 +45,9 @@ private function grabFromDB()
'profile.avatar_thumb',
'profile.small_id',
'profile_ban.vac',
'profile_ban.vac_banned_on',
'profile_ban.vac_bans',
'profile_ban.game_bans',
'profile_ban.last_ban_date',
'profile_ban.community',
'profile_ban.trade',
@@ -104,16 +63,17 @@ private function grabFromDB()
foreach($userListProfiles as $userListProfile)
{
$vacBanDate = new DateTime($userListProfile->vac_banned_on);
$lastBanDate = new DateTime($userListProfile->last_ban_date);
$return[] = [
'id' => $userListProfile->id,
'display_name' => $userListProfile->display_name,
'avatar_thumb' => $userListProfile->avatar_thumb,
'small_id' => $userListProfile->small_id,
'steam_64_bit' => Steam::to64Bit($userListProfile->small_id),
'vac' => $userListProfile->vac,
'vac_banned_on' => $vacBanDate->format("M j Y"),
'vac_bans' => $userListProfile->vac_bans,
'game_bans' => $userListProfile->game_bans,
'last_ban_date' => $lastBanDate->format("M j Y"),
'community' => $userListProfile->community,
'trade' => $userListProfile->trade,
'site_admin' => (int) $userListProfile->site_admin?:0,
Oops, something went wrong.

0 comments on commit f80cf44

Please sign in to comment.