-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement telemetry settings (#225) * Implement telemetry * Show telemetry documentation link * Implement telemetry send command and cron * Simplify `send` method * Extend telemetry model * Simplify config route; Add link to config form * Use JsonSerializable and MessageCountAwareInterface * Fix downloads fields * Limit requests to date * Add `technical_email` to instance config * Handle null values; Fix tests * Revert technical email * Use JsonSerializable * Update sqls * Change status code and sync packages count * Improve tests * Fix config controller; Use constants * Update tests and docsUrl
- Loading branch information
Showing
33 changed files
with
1,115 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*/5 * * * * /app/bin/console repman:proxy:sync-releases | ||
*/6 * * * * /app/bin/console repman:proxy:sync-metadata | ||
0 */2 * * * /app/bin/console repman:security:update-db | ||
0 0 * * * /app/bin/console repman:telemetry:send |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buddy\Repman\Command; | ||
|
||
use Buddy\Repman\Service\Config; | ||
use Buddy\Repman\Service\Telemetry; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
final class SendTelemetryCommand extends Command | ||
{ | ||
private Config $config; | ||
private Telemetry $telemetry; | ||
|
||
public function __construct(Config $config, Telemetry $telemetry) | ||
{ | ||
$this->config = $config; | ||
$this->telemetry = $telemetry; | ||
|
||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('repman:telemetry:send') | ||
->setDescription('Send telemetry data'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
if (!$this->telemetry->isInstanceIdPresent()) { | ||
return 0; | ||
} | ||
|
||
if (!$this->config->telemetryEnabled()) { | ||
return 0; | ||
} | ||
|
||
$this->telemetry | ||
->collectAndSend((new \DateTimeImmutable())->modify('-1 day')); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buddy\Repman\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20200723105216 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); | ||
|
||
$this->addSql("INSERT INTO config (key, value) VALUES ('telemetry', 'disabled')"); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); | ||
|
||
$this->addSql("DELETE FROM config WHERE key IN ('telemetry'"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buddy\Repman\Query\Admin; | ||
|
||
use Buddy\Repman\Service\Telemetry\Entry\Organization; | ||
use Buddy\Repman\Service\Telemetry\Entry\Package; | ||
|
||
interface TelemetryQuery | ||
{ | ||
/** | ||
* @return Organization[] | ||
*/ | ||
public function organizations(int $limit = 100, int $offset = 0): array; | ||
|
||
public function organizationsCount(): int; | ||
|
||
/** | ||
* @return Package[] | ||
*/ | ||
public function packages(string $organizationId, \DateTimeImmutable $till, int $limit = 100, int $offset = 0): array; | ||
|
||
public function packagesCount(string $organizationId): int; | ||
|
||
public function usersCount(): int; | ||
|
||
public function privateDownloads(\DateTimeImmutable $till): int; | ||
|
||
public function proxyDownloads(\DateTimeImmutable $till): int; | ||
} |
Oops, something went wrong.