Skip to content

Commit

Permalink
Use epoch 0 instead of 0000-00-00 to denote anytime (pokepark#174)
Browse files Browse the repository at this point in the history
* Use epoch 0 instead of 0000-00-00 to denote anytime

Fixes issue#148
  • Loading branch information
jinnatar authored Sep 8, 2020
1 parent c5de551 commit 8a4c79d
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.250.1
2.0.252.1
2 changes: 1 addition & 1 deletion config/config.json.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"VERSION":"2.0.250.1",
"VERSION":"2.0.252.1",
"DB_HOST":"localhost",
"DB_NAME":"your_database_name",
"DB_USER":"your_database_user",
Expand Down
4 changes: 4 additions & 0 deletions constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
// raid level constants
define('RAID_LEVEL_ALL', '654321');

// Value used for denoting anytime attendance
define('ANYTIME', '1970-01-01 00:00:00');
define('ANYTIME_TS', preg_replace("/[^0-9]/", "", ANYTIME));

// Icons.
defined('TEAM_B') or define('TEAM_B', iconv('UCS-4LE', 'UTF-8', pack('V', 0x1F499)));
defined('TEAM_R') or define('TEAM_R', iconv('UCS-4LE', 'UTF-8', pack('V', 0x2764)));
Expand Down
2 changes: 1 addition & 1 deletion logic/check_time.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
function check_time($time)
{
// Raid anytime?
if(strcmp($time,'0000-00-00 00:00:00')===0){
if(strcmp($time, ANYTIME)===0){
return getTranslation('anytime');
} else {
return dt2time($time);
Expand Down
2 changes: 1 addition & 1 deletion logic/get_remote_users_count.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function get_remote_users_count($raid_id, $user_id, $attend_time = false)
// Ignore max limit if attend time is 'Anytime'
$rs = my_query(
"
SELECT IF(attend_time = '0000-00-00 00:00:00',0,sum(1 + extra_mystic + extra_valor + extra_instinct)) AS remote_users
SELECT IF(attend_time = '" . ANYTIME . "',0,sum(1 + extra_mystic + extra_valor + extra_instinct)) AS remote_users
FROM (SELECT DISTINCT user_id, extra_mystic, extra_valor, extra_instinct, remote, attend_time FROM attendance WHERE remote = 1 AND cancel = 0 AND raid_done = 0) as T
WHERE attend_time = {$att_sql}
GROUP BY attend_time
Expand Down
8 changes: 4 additions & 4 deletions logic/show_raid_poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function show_raid_poll($raid)
// Hide participants?
if($config->RAID_POLL_HIDE_USERS_TIME > 0) {
if($config->RAID_ANYTIME) {
$hide_users_sql = "AND (attend_time > (UTC_TIMESTAMP() - INTERVAL " . $config->RAID_POLL_HIDE_USERS_TIME . " MINUTE) OR attend_time = 0)";
$hide_users_sql = "AND (attend_time > (UTC_TIMESTAMP() - INTERVAL " . $config->RAID_POLL_HIDE_USERS_TIME . " MINUTE) OR attend_time = '". ANYTIME ."')";
} else {
$hide_users_sql = "AND attend_time > (UTC_TIMESTAMP() - INTERVAL " . $config->RAID_POLL_HIDE_USERS_TIME . " MINUTE)";
}
Expand Down Expand Up @@ -289,7 +289,7 @@ function show_raid_poll($raid)
if($previous_att_time != $current_att_time) {
// Add to message.
$count_att_time_extrapeople = $cnt[$current_att_time]['extra_mystic'] + $cnt[$current_att_time]['extra_valor'] + $cnt[$current_att_time]['extra_instinct'];
$msg = raid_poll_message($msg, CR . '<b>' . (($current_att_time == 0) ? (getPublicTranslation('anytime')) : ($dt_att_time)) . '</b>');
$msg = raid_poll_message($msg, CR . '<b>' . (($current_att_time == ANYTIME_TS) ? (getPublicTranslation('anytime')) : ($dt_att_time)) . '</b>');

// Hide if other pokemon got selected. Show attendances for each pokemon instead of each attend time.
$msg = raid_poll_message($msg, (($cnt[$current_att_time]['count_other_pokemon'] == 0) ? (' [' . ($cnt[$current_att_time]['count'] + $count_att_time_extrapeople) . ']') : ''));
Expand Down Expand Up @@ -467,8 +467,8 @@ function show_raid_poll($raid)
$msg = raid_poll_message($msg, ($row['level'] == 0) ? ('<b>00</b> ') : (($row['level'] < 10) ? ('<b>0' . $row['level'] . '</b> ') : ('<b>' . $row['level'] . '</b> ')));
$msg = raid_poll_message($msg, '<a href="tg://user?id=' . $row['user_id'] . '">' . htmlspecialchars($row['name']) . '</a> ');
$msg = raid_poll_message($msg, ($raid_level == 'X' && $row['invite']) ? (EMOJI_INVITE . ' ') : '');
$msg = raid_poll_message($msg, ($row['cancel'] == 1) ? ('[' . (($row['ts_att'] == 0) ? (getPublicTranslation('anytime')) : ($dt_att_time)) . '] ') : '');
$msg = raid_poll_message($msg, ($row['raid_done'] == 1) ? ('[' . (($row['ts_att'] == 0) ? (getPublicTranslation('anytime')) : ($dt_att_time)) . '] ') : '');
$msg = raid_poll_message($msg, ($row['cancel'] == 1) ? ('[' . (($row['ts_att'] == ANYTIME_TS) ? (getPublicTranslation('anytime')) : ($dt_att_time)) . '] ') : '');
$msg = raid_poll_message($msg, ($row['raid_done'] == 1) ? ('[' . (($row['ts_att'] == ANYTIME_TS) ? (getPublicTranslation('anytime')) : ($dt_att_time)) . '] ') : '');
$msg = raid_poll_message($msg, ($row['extra_mystic']) ? ('+' . $row['extra_mystic'] . TEAM_B . ' ') : '');
$msg = raid_poll_message($msg, ($row['extra_valor']) ? ('+' . $row['extra_valor'] . TEAM_R . ' ') : '');
$msg = raid_poll_message($msg, ($row['extra_instinct']) ? ('+' . $row['extra_instinct'] . TEAM_Y . ' ') : '');
Expand Down
2 changes: 1 addition & 1 deletion mods/vote_time.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// Raid anytime?
if($arg == 0) {
// Raid anytime.
$attend_time = '0000-00-00 00:00:00';
$attend_time = ANYTIME;
} else {
// Normal raid time - convert data arg to UTC time.
$dt = new DateTime();
Expand Down

0 comments on commit 8a4c79d

Please sign in to comment.