Add language storage during server and profile polling
- Add index on language field in profile and server tables
This commit is contained in:
parent
650f0b4009
commit
bc5a0fb590
|
@ -85,9 +85,9 @@ class Profile extends \Friendica\Directory\Model
|
|||
'limit' => [$limit, \PDO::PARAM_INT]
|
||||
]);
|
||||
|
||||
$stmt = 'SELECT p.`id`, p.`name`, p.`username`, p.`addr`, p.`account_type`, p.`pdesc`,
|
||||
p.`locality`, p.`region`, p.`country`, p.`profile_url`, p.`dfrn_request`, p.`photo`,
|
||||
p.`tags`, p.`last_activity`
|
||||
$stmt = 'SELECT p.`id`, p.`name`, p.`username`, p.`addr`, p.`account_type`, p.`language`,
|
||||
p.`pdesc`, p.`locality`, p.`region`, p.`country`, p.`profile_url`, p.`dfrn_request`,
|
||||
p.`photo`, p.`tags`, p.`last_activity`
|
||||
FROM `profile` p
|
||||
JOIN `server` s ON s.`id` = p.`server_id` AND s.`available` AND NOT s.`hidden`
|
||||
WHERE p.`available`
|
||||
|
|
|
@ -137,6 +137,7 @@ class Profile
|
|||
} else {
|
||||
$this->logger->notice('Parsing profile page ' . $profile_uri);
|
||||
$params = \Friendica\Directory\Utils\Scrape::retrieveProfileData($profile_uri);
|
||||
$params['language'] = $server['language'];
|
||||
}
|
||||
|
||||
// Empty result is due to an offline site.
|
||||
|
@ -195,8 +196,32 @@ class Profile
|
|||
|
||||
$filled_fields = intval(!empty($params['pdesc'])) * 4 + intval(!empty($params['tags'])) * 2 + intval(!empty($params['locality']) || !empty($params['region']) || !empty($params['country-name']));
|
||||
|
||||
$this->logger->debug(var_export($params, true));
|
||||
|
||||
$values = [
|
||||
'profile_id' => $profile_id,
|
||||
'server_id' => $server['id'],
|
||||
'username' => $username,
|
||||
'name' => $params['fn'],
|
||||
'pdesc' => $params['pdesc'] ?? '',
|
||||
'locality' => $params['locality'] ?? '',
|
||||
'region' => $params['region'] ?? '',
|
||||
'country' => $params['country-name'] ?? '',
|
||||
'profile_url' => $profile_uri,
|
||||
'dfrn_request' => $params['dfrn-request'] ?? null,
|
||||
'photo' => $params['photo'],
|
||||
'tags' => implode(' ', $tags),
|
||||
'addr' => $addr,
|
||||
'account_type' => $account_type,
|
||||
'language' => $params['language'] ?? null,
|
||||
'filled_fields'=> $filled_fields,
|
||||
'last_activity'=> $params['last-activity'] ?? null,
|
||||
'available' => $available,
|
||||
];
|
||||
|
||||
$this->logger->debug(var_export($values, true));
|
||||
|
||||
$this->atlas->perform('INSERT INTO `profile` SET
|
||||
`id` = :profile_id,
|
||||
`server_id` = :server_id,
|
||||
`username` = :username,
|
||||
`name` = :name,
|
||||
|
@ -206,9 +231,11 @@ class Profile
|
|||
`country` = :country,
|
||||
`profile_url` = :profile_url,
|
||||
`dfrn_request` = :dfrn_request,
|
||||
`photo` = :photo,
|
||||
`tags` = :tags,
|
||||
`addr` = :addr,
|
||||
`account_type` = :account_type,
|
||||
`language` = :language,
|
||||
`filled_fields` = :filled_fields,
|
||||
`last_activity` = :last_activity,
|
||||
`available` = :available,
|
||||
|
@ -228,29 +255,12 @@ class Profile
|
|||
`tags` = :tags,
|
||||
`addr` = :addr,
|
||||
`account_type` = :account_type,
|
||||
`language` = :language,
|
||||
`filled_fields` = :filled_fields,
|
||||
`last_activity` = :last_activity,
|
||||
`available` = :available,
|
||||
`updated` = NOW()',
|
||||
[
|
||||
'profile_id' => $profile_id,
|
||||
'server_id' => $server['id'],
|
||||
'username' => $username,
|
||||
'name' => $params['fn'],
|
||||
'pdesc' => $params['pdesc'] ?? '',
|
||||
'locality' => $params['locality'] ?? '',
|
||||
'region' => $params['region'] ?? '',
|
||||
'country' => $params['country-name'] ?? '',
|
||||
'profile_url' => $profile_uri,
|
||||
'dfrn_request' => $params['dfrn-request'] ?? null,
|
||||
'photo' => $params['photo'],
|
||||
'tags' => implode(' ', $tags),
|
||||
'addr' => $addr,
|
||||
'account_type' => $account_type,
|
||||
'filled_fields' => $filled_fields,
|
||||
'last_activity' => $params['last-activity'] ?? null,
|
||||
'available' => $available,
|
||||
]
|
||||
$values
|
||||
);
|
||||
|
||||
if (!$profile_id) {
|
||||
|
|
|
@ -148,6 +148,7 @@ class Server
|
|||
`last_seen` = NOW(),
|
||||
`base_url` = :base_url,
|
||||
`name` = :name,
|
||||
`language` = :language,
|
||||
`version` = :version,
|
||||
`addons` = :addons,
|
||||
`reg_policy` = :reg_policy,
|
||||
|
@ -161,6 +162,7 @@ class Server
|
|||
'server_id' => $server['id'],
|
||||
'base_url' => strtolower($probe_result['data']['url']),
|
||||
'name' => $probe_result['data']['site_name'],
|
||||
'language' => $probe_result['data']['language'] ?? null,
|
||||
'version' => $probe_result['data']['version'],
|
||||
'addons' => implode(',', $addons),
|
||||
'reg_policy' => $probe_result['data']['register_policy'],
|
||||
|
|
3
src/sql/migrations/down/0002.sql
Normal file
3
src/sql/migrations/down/0002.sql
Normal file
|
@ -0,0 +1,3 @@
|
|||
ALTER table `profile` DROP KEY `language` (`language`);
|
||||
|
||||
ALTER table `server` DROP KEY `language` (`language`);
|
3
src/sql/migrations/up/0003.sql
Normal file
3
src/sql/migrations/up/0003.sql
Normal file
|
@ -0,0 +1,3 @@
|
|||
ALTER table `profile` ADD KEY `language` (`language`);
|
||||
|
||||
ALTER table `server` ADD KEY `language` (`language`);
|
Loading…
Reference in a new issue