Skip to content

Commit 71bda0f

Browse files
committed
5.8.0
1 parent e5989c2 commit 71bda0f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2136
-1143
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish Docker devel image
2+
3+
on:
4+
push:
5+
branches: [ devel ]
6+
7+
jobs:
8+
push_to_registry:
9+
name: Push Docker image to Docker Hub
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
steps:
14+
- name: Check out the repo
15+
uses: actions/checkout@v4
16+
with:
17+
ref: 'devel'
18+
19+
- name: Retrieve Repomanager version
20+
run: |
21+
echo "VERSION=$(cat ${GITHUB_WORKSPACE}/www/version)" >> $GITHUB_ENV
22+
echo "Version: ${{ env.VERSION }}"
23+
24+
- name: Set up QEMU
25+
uses: docker/setup-qemu-action@v3
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
30+
- name: Log in to the container registry
31+
uses: docker/login-action@v3
32+
with:
33+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
34+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
35+
36+
# Build the images
37+
- name: Build and push docker
38+
uses: docker/build-push-action@v6
39+
with:
40+
file: Dockerfile
41+
push: true
42+
tags: lbr38/repomanager:devel
43+
platforms: linux/amd64,linux/arm64,linux/arm/v7
44+
cache-from: type=gha
45+
cache-to: type=gha,mode=max

.github/workflows/test-database-update.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
2323
# Get all releases
2424
# Format them to a key-value array
25-
# Start from release index which is 4.0.0
26-
# Pull images starting from release 4.0.0
25+
# Start from release index which is 5.1.0
26+
# Pull images starting from release 5.1.0
2727
# Then pull the next image of the index, etc..
2828
- name: Test all release updates from lbr38/repomanager
2929
run: |
@@ -37,7 +37,7 @@ jobs:
3737
done
3838
3939
for i in "${!RELEASES_ARRAY[@]}"; do
40-
if [[ "${RELEASES_ARRAY[$i]}" == "4.0.0" ]]; then
40+
if [[ "${RELEASES_ARRAY[$i]}" == "5.1.0" ]]; then
4141
start_index="$i"
4242
break
4343
fi

www/bin/repomanager

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ function permissions
8181
find "$DATA_DIR" -type f -exec chmod 0660 {} \; > /dev/null 2>&1 &
8282

8383
# Permissions on repos directory
84-
find "$REPOS_DIR" -type d -exec chmod 0770 {} \; > /dev/null 2>&1 &
85-
find "$REPOS_DIR" -type f -exec chmod 0660 {} \; > /dev/null 2>&1 &
84+
# find "$REPOS_DIR" -type d -exec chmod 0770 {} \; > /dev/null 2>&1 &
85+
# find "$REPOS_DIR" -type f -exec chmod 0660 {} \; > /dev/null 2>&1 &
8686
}
8787

8888
echo '

www/controllers/Environment.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ public function __construct()
1414
$this->model = new \Models\Environment();
1515
}
1616

17+
/**
18+
* Return all environments name
19+
*/
20+
public function getAllByName(): array
21+
{
22+
return $this->model->getAllByName();
23+
}
24+
1725
/**
1826
* Get environment color
1927
*/

www/controllers/Layout/Chart/vars/repo-access-chart.vars.inc.php

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
$repoController = new \Controllers\Repo\Repo();
3+
$repoEnvController = new \Controllers\Repo\Environment();
4+
$envController = new \Controllers\Environment();
5+
$debRepoStatController = new \Controllers\Repo\Statistic\Deb();
6+
$rpmRepoStatController = new \Controllers\Repo\Statistic\Rpm();
7+
$datasets = [];
8+
$labels = [];
9+
$options = [];
10+
11+
// Check that repository Id is specified
12+
if (empty(__ACTUAL_URI__[3])) {
13+
throw new Exception('no repository ID specified');
14+
}
15+
16+
// Check that repository Id is valid
17+
if (!is_numeric(__ACTUAL_URI__[3])) {
18+
throw new Exception('invalid repository ID');
19+
}
20+
21+
// Retrieve repo infos from DB
22+
$repoController->getAllById(__ACTUAL_URI__[3], '', '');
23+
24+
// Get all environments associated to the repository and all current environments (to display in the chart even if they are not associated to the repository)
25+
$envs = array_unique(array_merge($repoEnvController->getByRepoId(__ACTUAL_URI__[3]), $envController->getAllByName()));
26+
27+
// Quit if no environment is associated to the repository
28+
if (empty($envs)) {
29+
return;
30+
}
31+
32+
$allTimestamps = [];
33+
$envData = [];
34+
35+
foreach ($envs as $env) {
36+
if ($repoController->getPackageType() == 'rpm') {
37+
$results = $rpmRepoStatController->getAccessByPeriod($repoController->getName(), $repoController->getReleasever(), $env, $timeStart, $timeEnd);
38+
}
39+
if ($repoController->getPackageType() == 'deb') {
40+
$results = $debRepoStatController->getAccessByPeriod($repoController->getName(), $repoController->getDist(), $repoController->getSection(), $env, $timeStart, $timeEnd);
41+
}
42+
43+
// Transform the results into an associative format timestamp => count
44+
$envTimestamps = [];
45+
if (!empty($results)) {
46+
foreach ($results as $row) {
47+
$timestamp = $row['Timestamp'] * 1000;
48+
$envTimestamps[$timestamp] = $row['Count'];
49+
}
50+
}
51+
52+
// Add the final point
53+
$currentTimestamp = time() * 1000;
54+
$envTimestamps[$currentTimestamp] = 0;
55+
56+
// Collect all unique timestamps
57+
$allTimestamps = array_merge($allTimestamps, array_keys($envTimestamps));
58+
59+
// Store the data for this environment
60+
$envData[] = [
61+
'name' => $env,
62+
'timestamps' => $envTimestamps,
63+
'color' => \Controllers\Environment::getEnvColor($env)
64+
];
65+
}
66+
67+
// Create unique and sorted labels
68+
$labels = array_values(array_unique($allTimestamps));
69+
sort($labels);
70+
71+
// Build the final datasets using array_map for optimization
72+
$datasets = array_map(function ($env) use ($labels) {
73+
return [
74+
'name' => $env['name'],
75+
'data' => array_map(fn($timestamp) => $env['timestamps'][$timestamp] ?? 0, $labels),
76+
'color' => $env['color']
77+
];
78+
}, $envData);
79+
80+
// Calculate totals for each timestamp and add Total dataset
81+
// $totalData = [];
82+
// foreach ($labels as $timestamp) {
83+
// $total = 0;
84+
// foreach ($envData as $env) {
85+
// $total += $env['timestamps'][$timestamp] ?? 0;
86+
// }
87+
// $totalData[] = $total;
88+
// }
89+
90+
// // Add Total dataset with green color
91+
// $datasets[] = [
92+
// 'name' => 'Total',
93+
// 'data' => $totalData,
94+
// 'color' => '#15bf7f'
95+
// ];
96+
97+
// Configure tooltip options with axis pointer for line charts
98+
$options = [
99+
'tooltip' => [
100+
'trigger' => 'axis',
101+
'axisPointer' => [
102+
'type' => 'line',
103+
'animation' => false,
104+
'label' => [
105+
'backgroundColor' => '#505765'
106+
]
107+
]
108+
]
109+
];
110+
111+
unset($repoController, $repoEnvController, $debRepoStatController, $rpmRepoStatController, $envData, $allTimestamps, $envTimestamps, $results);
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
use \Controllers\Filesystem\Directory;
3+
4+
$repoController = new \Controllers\Repo\Repo();
5+
$datasets = [];
6+
$labels = [];
7+
$options = [];
8+
9+
if (__ACTUAL_URI__[2] != 'repo') {
10+
throw new Exception('Error: invalid URI specified.');
11+
}
12+
13+
if (empty(__ACTUAL_URI__[3])) {
14+
throw new Exception('Error: missing repository ID.');
15+
}
16+
17+
if (!is_numeric(__ACTUAL_URI__[3])) {
18+
throw new Exception('Error: invalid repository ID specified.');
19+
}
20+
21+
// Get repository info
22+
$repoController->getAllById(__ACTUAL_URI__[3]);
23+
24+
// Get all snapshots of the repository
25+
$snapshots = $repoController->getSnapshots($repoController->getRepoId());
26+
27+
// Initialize dataset with proper name
28+
$datasets[0] = [
29+
'name' => 'Snapshot size (MB)',
30+
'data' => [],
31+
'snapshotIds' => [] // Store snapshot IDs for click handling
32+
];
33+
34+
foreach ($snapshots as $snapshot) {
35+
$labels[] = strtotime($snapshot['Date']) * 1000;
36+
37+
if ($repoController->getPackageType() == 'deb') {
38+
$snapshotPath = REPOS_DIR . '/deb/' . $repoController->getName() . '/' . $repoController->getDist() . '/' . $repoController->getSection() . '/' . $snapshot['Date'];
39+
} else if ($repoController->getPackageType() == 'rpm') {
40+
$snapshotPath = REPOS_DIR . '/rpm/' . $repoController->getName() . '/' . $repoController->getReleasever() . '/' . $snapshot['Date'];
41+
}
42+
43+
// Get snapshot size in bytes
44+
$size = Directory::getSize($snapshotPath);
45+
46+
// Convert it in MB (1 MB = 1024 * 1024 bytes)
47+
$size = $size / (1024 * 1024);
48+
49+
$datasets[0]['data'][] = $size;
50+
$datasets[0]['snapshotIds'][] = $snapshot['Id']; // Store for click handling
51+
}
52+
53+
$options = [
54+
// Show labels directly on the chart
55+
'showAsLabels' => true,
56+
57+
// Labels format and style
58+
'labelPosition' => 'auto', // 'top', 'bottom', 'left', 'right', 'inside', 'auto' (adaptive)
59+
'labelColor' => '#FFFFFF',
60+
'labelFontSize' => 12,
61+
'labelFontWeight' => 'bold',
62+
'labelFontFamily' => 'Arial, sans-serif',
63+
'labelBackground' => 'rgb(46, 54, 58)',
64+
'labelBorder' => false,
65+
'labelBorderRadius' => 16,
66+
'labelPadding' => [6, 15],
67+
68+
// Drop shadow (optional)
69+
'labelShadow' => true,
70+
71+
// Date format
72+
'labelDateFormat' => 'fr-FR', // Locale for dates
73+
'labelDateSeparator' => '-', // Date separator ('-' or '/' or '.')
74+
'labelDateOptions' => [ // Date formatting options
75+
'day' => '2-digit',
76+
'month' => '2-digit',
77+
'year' => 'numeric'
78+
],
79+
80+
'legend' => [
81+
'show' => false
82+
],
83+
'toolbox' => [
84+
'show' => false
85+
],
86+
'tooltip' => [
87+
'show' => true,
88+
'valueUnit' => 'MB', // Unit to display after values in tooltip
89+
'valuePrecision' => 2 // Number of decimals for values
90+
],
91+
92+
// Configure click callback to redirect to snapshot page
93+
'clickCallback' => [
94+
'enabled' => true,
95+
'url' => '/browse/{value}',
96+
'newTab' => false // '_self' for same tab, '_blank' for new tab
97+
]
98+
];
99+
100+
unset($snapshotPath, $size, $snapshot, $snapshots, $repoController);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
$repoController = new \Controllers\Repo\Repo();
3+
$repoStatsController = new \Controllers\Repo\Statistic\Statistic();
4+
$datasets = [];
5+
$labels = [];
6+
$options = [];
7+
8+
if (__ACTUAL_URI__[2] != 'repo') {
9+
throw new Exception('Error: invalid URI specified.');
10+
}
11+
12+
if (empty(__ACTUAL_URI__[3])) {
13+
throw new Exception('Error: missing repository ID.');
14+
}
15+
16+
if (!is_numeric(__ACTUAL_URI__[3])) {
17+
throw new Exception('Error: invalid repository ID specified.');
18+
}
19+
20+
// Get repository info
21+
$repoController->getAllById(__ACTUAL_URI__[3]);
22+
23+
// Get all statistics for the specified repo ID
24+
$stats = $repoStatsController->getByRepoId(__ACTUAL_URI__[3]);
25+
26+
$snapData = [];
27+
28+
foreach ($stats as $stat) {
29+
if (!isset($labels[$stat['Timestamp'] * 1000])) {
30+
$labels[] = $stat['Timestamp'] * 1000;
31+
}
32+
33+
// Store the snapshot size for this timestamp
34+
$snapData[$stat['Snapshot_date']] = [
35+
'timestamp' => $stat['Timestamp'] * 1000,
36+
'size' => $stat['Snapshot_size'],
37+
];
38+
}
39+
40+
unset($repoController, $repoStatsController);

www/controllers/Layout/Chart/vars/repo-packages-count-chart.vars.inc.php renamed to www/controllers/Layout/Chart/vars/to_delete_repo-packages-count-chart.vars.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
// TODO: to delete later
23
$statsController = new \Controllers\Stat();
34
$datasets = [];
45
$labels = [];

www/controllers/Layout/Chart/vars/repo-size-chart.vars.inc.php renamed to www/controllers/Layout/Chart/vars/to_delete_repo-size-chart.vars.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
// TODO: to delete later
23
$statsController = new \Controllers\Stat();
34
$datasets = [];
45
$labels = [];

0 commit comments

Comments
 (0)