Added Location field to summit metric
Change-Id: Ib8c9f96437e2414ce4d46714f8724330de2dbfc5 Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
6dbcde8f57
commit
420c42fbe6
|
@ -85,6 +85,7 @@ final class OAuth2SummitMetricsApiController extends OAuth2ProtectedController
|
||||||
[
|
[
|
||||||
'type' => 'required|string|in:'.implode(",", ISummitMetricType::ValidTypes),
|
'type' => 'required|string|in:'.implode(",", ISummitMetricType::ValidTypes),
|
||||||
'source_id' => 'sometimes|integer',
|
'source_id' => 'sometimes|integer',
|
||||||
|
'location' => 'sometimes|string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($validation->fails()) {
|
if ($validation->fails()) {
|
||||||
|
@ -142,7 +143,7 @@ final class OAuth2SummitMetricsApiController extends OAuth2ProtectedController
|
||||||
[
|
[
|
||||||
'type' => 'required|string|in:'.implode(",", ISummitMetricType::ValidTypes),
|
'type' => 'required|string|in:'.implode(",", ISummitMetricType::ValidTypes),
|
||||||
'source_id' => 'sometimes|integer',
|
'source_id' => 'sometimes|integer',
|
||||||
|
'location' => 'sometimes|string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($validation->fails()) {
|
if ($validation->fails()) {
|
||||||
|
|
|
@ -58,6 +58,8 @@ final class SummitMetricFactory
|
||||||
public static function populate(SummitMetric $metric, array $data):SummitMetric{
|
public static function populate(SummitMetric $metric, array $data):SummitMetric{
|
||||||
if(isset($data['type']))
|
if(isset($data['type']))
|
||||||
$metric->setType($data['type']);
|
$metric->setType($data['type']);
|
||||||
|
if(isset($data['location']))
|
||||||
|
$metric->setLocation(urldecode($data['location']));
|
||||||
return $metric;
|
return $metric;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -69,6 +69,12 @@ class SummitMetric extends SilverstripeBaseModel
|
||||||
*/
|
*/
|
||||||
protected $origin;
|
protected $origin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(name="Location", type="string")
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(name="Browser", type="string")
|
* @ORM\Column(name="Browser", type="string")
|
||||||
* @var string|null
|
* @var string|null
|
||||||
|
@ -231,4 +237,21 @@ class SummitMetric extends SilverstripeBaseModel
|
||||||
{
|
{
|
||||||
return $this->browser;
|
return $this->browser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getLocation(): ?string
|
||||||
|
{
|
||||||
|
return $this->location;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string|null $location
|
||||||
|
*/
|
||||||
|
public function setLocation(?string $location): void
|
||||||
|
{
|
||||||
|
$this->location = $location;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php namespace Database\Migrations\Model;
|
||||||
|
/**
|
||||||
|
* Copyright 2019 OpenStack Foundation
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
**/
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
use Doctrine\DBAL\Schema\Schema as Schema;
|
||||||
|
use LaravelDoctrine\Migrations\Schema\Builder;
|
||||||
|
use LaravelDoctrine\Migrations\Schema\Table;
|
||||||
|
/**
|
||||||
|
* Class Version20201016145706
|
||||||
|
* @package Database\Migrations\Model
|
||||||
|
*/
|
||||||
|
class Version20201016145706 extends AbstractMigration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Schema $schema
|
||||||
|
*/
|
||||||
|
public function up(Schema $schema)
|
||||||
|
{
|
||||||
|
$builder = new Builder($schema);
|
||||||
|
if($schema->hasTable("SummitMetric") && !$builder->hasColumn("SummitMetric","Location") ) {
|
||||||
|
$builder->table('SummitMetric', function (Table $table) {
|
||||||
|
$table->text('Location')->setDefault(null)->setNotnull(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Schema $schema
|
||||||
|
*/
|
||||||
|
public function down(Schema $schema)
|
||||||
|
{
|
||||||
|
$builder = new Builder($schema);
|
||||||
|
if($schema->hasTable("SummitMetric") && $builder->hasColumn("SummitMetric","Location") ) {
|
||||||
|
$builder->table('SummitMetric', function (Table $table) {
|
||||||
|
$table->dropColumn('Location');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue