Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8c8610c
Began working on new Issue URL feature #99
dxL1nus Mar 2, 2026
148c6bc
Funtionality for new github issue URL now exists, but API enpoint not…
dxL1nus Mar 3, 2026
2a46707
Added core functionality for new Issue Url #99
dxL1nus Mar 3, 2026
8ab30fc
reserve Identifier now with one API route and modes #99
dxL1nus Mar 5, 2026
734ec38
Initilially it works to link and existing github issue through the id…
dxL1nus Mar 6, 2026
3654b03
different states for isIdentifierReserved and one for isIssueLinked #62
dxL1nus Mar 7, 2026
45128a3
Article Title is now being displayed in the newly created Issue, issu…
dxL1nus Mar 7, 2026
7386d37
Unit tests, and cypress tests work now #118
dxL1nus Jun 8, 2026
fe48545
Now repositories and codecheckers are in the issue #53
dxL1nus Mar 12, 2026
f28db9a
#62, #99: When Issue with Identifier is reserved automatically, then …
dxL1nus Mar 12, 2026
0335d42
#62, #99: Input readonly, when GitHub Issue Url exists and Input has …
dxL1nus Mar 12, 2026
13709c1
Proper fail message when update of issue fails #53
dxL1nus Mar 12, 2026
b1bf4bd
#99 first steps to make this branch work again
dxL1nus Jun 7, 2026
347676a
Now all GitHub Issue Labels are in one array, no spearate Venue Type …
dxL1nus Mar 23, 2026
acf0940
GitHub Issue Labels are now saved in and loaded from CODECHECK Metada…
dxL1nus Mar 23, 2026
5c1db99
Unit tests, and cypress tests work now #118
dxL1nus Jun 8, 2026
361e028
Fixed small bug when identifier url is not set at all #62
dxL1nus May 3, 2026
d5d41fe
Added tests to gitignore
dxL1nus May 3, 2026
46e2638
Rebased main into this branch, so it is ready for the PR
dxL1nus May 3, 2026
cd6df83
#99 first steps to make this branch work again
dxL1nus Jun 7, 2026
51cf30b
62 Fixed bug with new Settings Form, Rebase completed
dxL1nus Jun 7, 2026
571d535
PHP Unit tests now work again #118
dxL1nus Jun 8, 2026
9890702
Unit tests, and cypress tests work now #118
dxL1nus Jun 8, 2026
c89a145
Fixed all bugs after rebase, now working perfectly fine #118
dxL1nus Jun 8, 2026
5c96f10
Unit tests should now work #118
dxL1nus Jun 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions CodecheckPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use APP\plugins\generic\codecheck\controllers\page\CodecheckPageHandler;
use APP\plugins\generic\codecheck\classes\CodecheckRoles\CodecheckRoleArray;
use APP\plugins\generic\codecheck\classes\CodecheckRoles\CodecheckRoleManager;
use APP\core\Request;

class CodecheckPlugin extends GenericPlugin
{
Expand Down Expand Up @@ -249,7 +250,7 @@ public function addOptInCheckbox(string $hookName, \PKP\components\forms\FormCom
$request = Application::get()->getRequest();
$context = $request->getContext();
$codecheckMode = $this->getSetting($context->getId(), Constants::CODECHECK_MODE);
error_log("[CODECHECK Settings] Mode: " . $codecheckMode);
CodecheckLogger::debug("Settings Mode: " . $codecheckMode);
$checkboxValue = false;
$checkboxDisabled = false;
$codecheckDescription = __('plugins.generic.codecheck.optIn.description', [
Expand Down Expand Up @@ -380,11 +381,13 @@ public function manage($args, $request): JSONMessage

public function setEnabled($enabled, $contextId = null)
{
CodecheckLogger::debug("Plugin Enabled!");
$result = parent::setEnabled($enabled, $contextId);

if ($enabled) {
$this->migration = new CodecheckSchemaMigration();
$this->migration->up();
$migration = new CodecheckSchemaMigration();
$migration->up();
$migration->issueLabelsUp();
}

return $result;
Expand All @@ -395,6 +398,8 @@ public function resetSchema(): void
$this->migration = new CodecheckSchemaMigration();
$this->migration->down();
$this->migration->up();
$this->migration->issueLabelsDown();
$this->migration->issueLabelsUp();
}
}

Expand Down
449 changes: 356 additions & 93 deletions api/v1/CodecheckApiHandler.php

Large diffs are not rendered by default.

114 changes: 89 additions & 25 deletions classes/CodecheckRegister/CertificateIdentifierList.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ function __construct()
* @return CertificateIdentifierList Returns a new List containing all fetched Certificate Identifiers from GitHub
*/
static function fromApi(
CodecheckGithubRegisterApiClient $codecheckGithubRegisterApiClient
CodecheckGithubRegisterApiClient $codecheckGithubRegisterApiClient,
?bool $onlyNewestIdentifiers
): CertificateIdentifierList {
$newCertificateIdentifierList = new CertificateIdentifierList();

// fetch API
try {
$codecheckGithubRegisterApiClient->fetchIssues();
if($onlyNewestIdentifiers == true) {
$codecheckGithubRegisterApiClient->fetchNewestIssues();
} else {
$codecheckGithubRegisterApiClient->fetchAllIssues();
}
} catch (ApiFetchException $ae) {
CodecheckLogger::error($ae->getMessage());
throw $ae;
Expand All @@ -45,7 +50,46 @@ static function fromApi(
throw $me;
}

foreach ($codecheckGithubRegisterApiClient->getIssues() as $issue) {
return CertificateIdentifierList::createNewCertificateIdentifierList(
$codecheckGithubRegisterApiClient->getIssues(),
$newCertificateIdentifierList
);
}

/**
* Factory Method to create a new CertificateIdentifierList from a GitHub API fetch
*
* @param CodecheckGithubRegisterApiClient $codecheckGithubRegisterApiClient The APIParser for the GitHub Issues
* @return CertificateIdentifierList Returns a new List containing all fetched Certificate Identifiers from GitHub
*/
static function fromApiWithIdentifier(
CodecheckGithubRegisterApiClient $codecheckGithubRegisterApiClient,
CertificateIdentifier $certificateIdentifier
): CertificateIdentifierList {
$newCertificateIdentifierList = new CertificateIdentifierList();

// fetch API
try {
$codecheckGithubRegisterApiClient->fetchIssueByIdentifier($certificateIdentifier);
} catch (ApiFetchException $ae) {
CodecheckLogger::error($ae->getMessage());
throw $ae;
} catch (NoMatchingIssuesFoundException $me) {
CodecheckLogger::error($me->getMessage());
throw $me;
}

return CertificateIdentifierList::createNewCertificateIdentifierList(
$codecheckGithubRegisterApiClient->getIssues(),
$newCertificateIdentifierList
);
}

private static function createNewCertificateIdentifierList(
array $issues,
CertificateIdentifierList $newCertificateIdentifierList
): CertificateIdentifierList {
foreach ($issues as $issue) {
// raw identifier (can still have ranges of identifiers);
$rawIdentifier = CertificateIdentifierList::getRawIdentifier($issue['title']);

Expand All @@ -56,7 +100,7 @@ static function fromApi(
}

// append to all identifiers in new Register
$newCertificateIdentifierList->appendToCertificateIdList($rawIdentifier);
$newCertificateIdentifierList->appendToCertificateIdList($rawIdentifier, $issue);
}

// return the new Register
Expand Down Expand Up @@ -98,10 +142,11 @@ public static function getRawIdentifier(string $title): ?string
/**
* Appends a raw Identifier to the list of Certificate Identifiers
*
* @param string $rawidentifier The raw Identifier to be appended
* @param string $rawIdentifier The raw Identifier to be appended
* @param array $issue The GitHub Issue information of the raw Identifier to be appended
* @return void
*/
public function appendToCertificateIdList(string $rawIdentifier): void
public function appendToCertificateIdList(string $rawIdentifier, array $issue): void
{
// list of certificate identifiers in range
$idRange = [];
Expand All @@ -111,25 +156,33 @@ public function appendToCertificateIdList(string $rawIdentifier): void
// split into "fromIdStr" and "toIdStr"
list($fromIdStr, $toIdStr) = explode('/', $rawIdentifier);

$from_identifier = CertificateIdentifier::fromStr($fromIdStr);
$to_identifier = CertificateIdentifier::fromStr($toIdStr);
$fromIdentifier = CertificateIdentifier::fromStr($fromIdStr);
$toIdentifier = CertificateIdentifier::fromStr($toIdStr);

// append to $idRange list
for ($id_count = $from_identifier->getNumber(); $id_count <= $to_identifier->getNumber(); $id_count++) {
$new_identifier = new CertificateIdentifier($from_identifier->getYear(), $id_count);
for ($id_count = $fromIdentifier->getNumber(); $id_count <= $toIdentifier->getNumber(); $id_count++) {
$newIdentifier = new CertificateIdentifier($fromIdentifier->getYear(), $id_count);
// append new identifier
$idRange[] = $new_identifier;
$idRange[] = [
'identifier' => $newIdentifier,
'issueUrl' => $issue['html_url'],
'issueNumber' => $issue['number']
];
}
}
// if it isn't a list then just append on identifier
else {
$new_identifier = CertificateIdentifier::fromStr($rawIdentifier);
$idRange[] = $new_identifier;
$newIdentifier = CertificateIdentifier::fromStr($rawIdentifier);
$idRange[] = [
'identifier' => $newIdentifier,
'issueUrl' => $issue['html_url'],
'issueNumber' => $issue['number']
];
}

// append to all certificate identifiers
foreach ($idRange as $identifier) {
if (!$this->uniqueArray->contains($identifier)) {
if (!$this->uniqueArray->containsIdentifier($identifier)) {
$this->uniqueArray->add($identifier);
}
}
Expand All @@ -142,11 +195,11 @@ public function sortAsc(): void
{
$this->uniqueArray->sort(function($a, $b) {
// First, compare year
if ($a->getYear() !== $b->getYear()) {
return $a->getYear() <=> $b->getYear();
if ($a['identifier']->getYear() !== $b['identifier']->getYear()) {
return $a['identifier']->getYear() <=> $b['identifier']->getYear();
}
// If years are equal, compare ID
return $a->getNumber() <=> $b->getNumber();
return $a['identifier']->getNumber() <=> $b['identifier']->getNumber();
});
}

Expand All @@ -157,11 +210,11 @@ public function sortDesc(): void
{
$this->uniqueArray->sort(function($a, $b) {
// First, compare year descending
if ($a->getYear() !== $b->getYear()) {
return $b->getYear() <=> $a->getYear();
if ($a['identifier']->getYear() !== $b['identifier']->getYear()) {
return $b['identifier']->getYear() <=> $a['identifier']->getYear();
}
// If years are equal, compare ID descending
return $b->getNumber() <=> $a->getNumber();
return $b['identifier']->getNumber() <=> $a['identifier']->getNumber();
});
}

Expand All @@ -184,7 +237,7 @@ public function getNewestIdentifier(): CertificateIdentifier
{
$this->sortDesc();
// get first element of sort descending -> newest element
return $this->uniqueArray->at(0);
return $this->uniqueArray->at(0)['identifier'];
}

/**
Expand All @@ -194,10 +247,21 @@ public function getNewestIdentifier(): CertificateIdentifier
*/
public function toStr(): string
{
$return_str = "Certificate Identifiers:\n";
foreach ($this->uniqueArray->toArray() as $identifier) {
$return_str .= $identifier->toStr() . "\n";
$returnStr = "Certificate Identifiers:\n";
foreach ($this->uniqueArray->toArray() as $identifierInformation) {
$returnStr .= $identifierInformation['identifier']->toStr() . "\n";
}
return $return_str;
return $returnStr;
}

public function getIssueInformationByIdentifier(CertificateIdentifier $identifier): ?array
{
foreach ($this->uniqueArray->toArray() as $identifierInformation) {
if($identifierInformation['identifier']->toStr() == $identifier->toStr()){
return $identifierInformation;
}
}

return null;
}
}
Loading
Loading