Skip to content

Commit

Permalink
another parse attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
dqwiki committed Sep 24, 2023
1 parent f8f2bcd commit f426f2b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions app/Http/Controllers/StatsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,21 @@ public function display_appeals_chart()
$reasons["{{".$matches[1]."}}"] = $reasons[$matches[1]] + 1;
}
} else {
//if reason doesn't have wikimarkup for a template, take anything before the last ":" and count them, otherwise ignore it
if (preg_match('/(.+):/', $appeal->blockreason, $matches)) {
if (!isset($reasons[$matches[1]])) {
$reasons[$matches[1]] = 1;
//if reason doesn't have wikimarkup for a template, take anything before the last ":", outside of a wikilink, and count them, otherwise ignore it
if (preg_match('/\[\[([^\]]+)\]\]/', $appeal->blockreason, $matches)) {
$reason = substr($matches[1], strrpos($matches[1], ':') + 1);
if (!isset($reasons[$reason])) {
$reasons[$reason] = 1;
} else {
$reasons[$matches[1]] = $reasons[$matches[1]] + 1;
$reasons[$reason] = $reasons[$reason] + 1;
}
} else {
$reasons['other'] = $reasons['other'] + 1;
$reason = substr($appeal->blockreason, strrpos($appeal->blockreason, ':') + 1);
if (!isset($reasons[$reason])) {
$reasons[$reason] = 1;
} else {
$reasons[$reason] = $reasons[$reason] + 1;
}
}
}
}
Expand Down

0 comments on commit f426f2b

Please sign in to comment.