Skip to content
This repository was archived by the owner on Apr 7, 2025. It is now read-only.

Commit b7e961b

Browse files
committed
Add downloads per day
1 parent a6879db commit b7e961b

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20240513141550 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return '';
18+
}
19+
20+
public function up(Schema $schema): void
21+
{
22+
// this up() migration is auto-generated, please modify it to your needs
23+
$this->addSql('ALTER TABLE theme ADD dpd_avg28 INT NOT NULL, ADD dpd_avg7 INT NOT NULL, ADD dpd_last_updated DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\'');
24+
$this->addSql('ALTER TABLE theme_author DROP author, DROP author_url');
25+
}
26+
27+
public function down(Schema $schema): void
28+
{
29+
// this down() migration is auto-generated, please modify it to your needs
30+
$this->addSql('ALTER TABLE theme DROP dpd_avg28, DROP dpd_avg7, DROP dpd_last_updated');
31+
$this->addSql('ALTER TABLE theme_author ADD author VARCHAR(255) DEFAULT NULL, ADD author_url VARCHAR(255) DEFAULT NULL');
32+
}
33+
}

src/Entity/Theme.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,34 @@ class Theme implements TimestampableInterface
177177
#[ORM\ManyToOne(targetEntity: self::class, fetch: 'EAGER')]
178178
private ?self $parent = null;
179179

180+
// ==========
181+
// Downloads per day
182+
// ==========
183+
184+
/**
185+
* The average number of downloads per day for the last 28 days.
186+
*
187+
* @var int|null
188+
*/
189+
#[ORM\Column]
190+
private ?int $dpdAvg28 = null; // phpcs:ignore Zend.NamingConventions.ValidVariableName.MemberVarContainsNumbers
191+
192+
/**
193+
* The average number of downloads per day for the last 7 days.
194+
*
195+
* @var int|null
196+
*/
197+
#[ORM\Column]
198+
private ?int $dpdAvg7 = null; // phpcs:ignore Zend.NamingConventions.ValidVariableName.MemberVarContainsNumbers
199+
200+
/**
201+
* The datetime of the last download count update.
202+
*
203+
* @var \DateTimeImmutable|null
204+
*/
205+
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
206+
private ?\DateTimeImmutable $dpdLastUpdated = null;
207+
180208
public function __construct()
181209
{
182210
$this->tags = new ArrayCollection();

0 commit comments

Comments
 (0)