Skip to content

2019 enhancement backend endpoint for hash heatmap#2068

Draft
jessevz wants to merge 2 commits into
devfrom
2019-enhancement-backend-endpoint-for-hash-heatmap
Draft

2019 enhancement backend endpoint for hash heatmap#2068
jessevz wants to merge 2 commits into
devfrom
2019-enhancement-backend-endpoint-for-hash-heatmap

Conversation

@jessevz
Copy link
Copy Markdown
Contributor

@jessevz jessevz commented May 12, 2026

closes #2019

@jessevz
Copy link
Copy Markdown
Contributor Author

jessevz commented May 13, 2026

hashtopolis/python-hashtopolis#4 Should be merged to pass the tests

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new APIv2 helper endpoint intended to move “cracks per day” aggregation (used for hash heatmaps) from the frontend to the backend (closes #2019).

Changes:

  • Added GET /api/v2/helper/getCracksPerDay which returns a date→count mapping of cracks for the current year.
  • Registered the new helper endpoint in the APIv2 router.
  • Added CI tests validating the new helper’s response shape and basic behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/inc/apiv2/helper/GetCracksPerDayHelperAPI.php Implements the new backend aggregation endpoint for cracked hashes per day.
src/api/v2/index.php Registers the new helper endpoint so it becomes reachable via APIv2.
ci/apiv2/test_cracks_per_day.py Adds CI coverage for the new helper endpoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +44 to +55
public function handleGet(Request $request, Response $response): Response {
$this->preCommon($request);

$yearStart = mktime(0, 0, 0, 1, 1, (int) date('Y'));
$now = time();

$filters = [
new QueryFilter(Hash::IS_CRACKED, 1, "="),
new QueryFilter(Hash::TIME_CRACKED, $yearStart, ">="),
new QueryFilter(Hash::TIME_CRACKED, $now, "<="),
];

}

public function getRequiredPermissions(string $method): array {
return [Hashlist::PERM_READ, Hash::PERM_READ];
Comment on lines +56 to +72
$counts = [];

foreach (Factory::getHashFactory()->filter([Factory::FILTER => $filters]) as $hash) {
$day = date('Y-m-d', $hash->getTimeCracked());
$counts[$day] = ($counts[$day] ?? 0) + 1;
}

$binaryFilters = [
new QueryFilter(HashBinary::IS_CRACKED, 1, "="),
new QueryFilter(HashBinary::TIME_CRACKED, $yearStart, ">="),
new QueryFilter(HashBinary::TIME_CRACKED, $now, "<="),
];

foreach (Factory::getHashBinaryFactory()->filter([Factory::FILTER => $binaryFilters]) as $hash) {
$day = date('Y-m-d', $hash->getTimeCracked());
$counts[$day] = ($counts[$day] ?? 0) + 1;
}
Comment on lines +41 to +42
* Returns a map of date -> crack count for every day from January 1st of the
* current year up to and including today.
@@ -0,0 +1,52 @@
import re
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants