Commit 9c26275e authored by mattwire's avatar mattwire

Add index to ip_address column

parent a501e077
......@@ -6,7 +6,7 @@
*
* Generated from /home/matthew/buildkit/build/d7master/web/sites/default/files/civicrm/ext/firewall/xml/schema/CRM/Firewall/FirewallIpaddress.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:fc7cd407630b3df83f5b3418b2cb5a9d)
* (GenCodeChecksum:ab0815dd500388bc6238265a1c19a2f7)
*/
/**
......@@ -95,6 +95,7 @@ class CRM_Firewall_DAO_FirewallIpaddress extends CRM_Core_DAO {
'type' => CRM_Utils_Type::T_STRING,
'title' => CRM_Firewall_ExtensionUtil::ts('IP Address'),
'description' => CRM_Firewall_ExtensionUtil::ts('IP address used'),
'required' => TRUE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
'where' => 'civicrm_firewall_ipaddress.ip_address',
......@@ -121,6 +122,7 @@ class CRM_Firewall_DAO_FirewallIpaddress extends CRM_Core_DAO {
'type' => CRM_Utils_Type::T_STRING,
'title' => CRM_Firewall_ExtensionUtil::ts('Event Type'),
'description' => CRM_Firewall_ExtensionUtil::ts('The type of event that triggered this log'),
'required' => TRUE,
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
'where' => 'civicrm_firewall_ipaddress.event_type',
......@@ -211,7 +213,16 @@ class CRM_Firewall_DAO_FirewallIpaddress extends CRM_Core_DAO {
* @return array
*/
public static function indices($localize = TRUE) {
$indices = [];
$indices = [
'index_ip_address' => [
'name' => 'index_ip_address',
'field' => [
0 => 'ip_address',
],
'localizable' => FALSE,
'sig' => 'civicrm_firewall_ipaddress::0::ip_address',
],
];
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
}
......
......@@ -26,7 +26,7 @@ class Firewall {
SELECT COUNT(*) as eventCount,event_type FROM `civicrm_firewall_ipaddress`
WHERE access_date >= DATE_SUB(NOW(), {$interval})
AND ip_address = %1
GROUP BY ip_address,event_type
GROUP BY event_type
";
$block = FALSE;
......
......@@ -50,15 +50,18 @@ CREATE TABLE `civicrm_firewall_ipaddress` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique FirewallIpaddress ID',
`ip_address` varchar(255) COMMENT 'IP address used',
`ip_address` varchar(255) NOT NULL COMMENT 'IP address used',
`access_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the IP address accessed',
`event_type` varchar(64) COMMENT 'The type of event that triggered this log',
`event_type` varchar(64) NOT NULL COMMENT 'The type of event that triggered this log',
`source` varchar(255) COMMENT 'Origin of this access request'
,
PRIMARY KEY (`id`)
, INDEX `index_ip_address`(
ip_address
)
) ;
\ No newline at end of file
......@@ -19,4 +19,4 @@ SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS `civicrm_firewall_ipaddress`;
SET FOREIGN_KEY_CHECKS=1;
SET FOREIGN_KEY_CHECKS=1;
\ No newline at end of file
......@@ -27,6 +27,10 @@
<comment>IP address used</comment>
<add>5.19</add>
</field>
<index>
<name>index_ip_address</name>
<fieldName>ip_address</fieldName>
</index>
<field>
<name>access_date</name>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment