Skip to content

Commit 900d3ba

Browse files
authored
Correct release report added counts (boostorg#1865)
1 parent cbd7814 commit 900d3ba

File tree

5 files changed

+52
-18
lines changed

5 files changed

+52
-18
lines changed

libraries/forms.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,10 @@ def get_stats(self):
751751
new_libraries = libraries.exclude(
752752
library_version__version__release_date__lte=prior_version.release_date
753753
).prefetch_related("authors")
754+
# TODO: we may in future need to find a way to show the removed libraries, for
755+
# now it's not needed. In that case the distinction between running this on a
756+
# ReportConfiguration with a real 'version' entry vs one that instead uses 'master'
757+
# will need to be considered
754758
top_contributors = self._get_top_contributors_for_version(version)
755759
# total messages sent during this release (version)
756760
total_mailinglist_count = EmailData.objects.filter(version=version).aggregate(
@@ -769,24 +773,16 @@ def get_stats(self):
769773
commit_contributors_release_count,
770774
commit_contributors_new_count,
771775
) = self._count_commit_contributors_totals(version, prior_version)
772-
library_count = LibraryVersion.objects.filter(
773-
version=version,
774-
library__in=self.library_queryset,
775-
).count()
776-
if prior_version:
777-
library_count_prior = LibraryVersion.objects.filter(
778-
version=prior_version,
779-
library__in=self.library_queryset,
780-
).count()
781-
else:
782-
library_count_prior = 0
783-
784-
added_library_count = max(0, library_count - library_count_prior)
785-
removed_library_count = max(0, library_count_prior - library_count)
776+
777+
added_library_count = new_libraries.count()
778+
# TODO: connected to above todo, add removed_libraries.count()
779+
removed_library_count = 0
780+
786781
lines_added = LibraryVersion.objects.filter(
787782
version=version,
788783
library__in=self.library_queryset,
789784
).aggregate(lines=Sum("insertions"))["lines"]
785+
790786
lines_removed = LibraryVersion.objects.filter(
791787
version=version,
792788
library__in=self.library_queryset,
@@ -856,8 +852,7 @@ def get_stats(self):
856852
"new_libraries": new_libraries,
857853
"batched_library_data": batched_library_data,
858854
"top_libraries_for_version": top_libraries_for_version,
859-
"library_count": library_count,
860-
"library_count_prior": library_count_prior,
855+
"library_count": libraries.count(),
861856
"library_index_libraries": library_index_library_data,
862857
"added_library_count": added_library_count,
863858
"removed_library_count": removed_library_count,

libraries/github.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def __init__(self, client=None, token=None):
204204
# of other modules. Identified by the key used in the libraries.json file.
205205
self.skip_libraries = ["chrono/stopwatch"]
206206

207-
def get_library_list(self, gitmodules=None):
207+
def get_library_list(self, gitmodules):
208208
"""
209209
Retrieve the full list of library data for Boost libraries from their Github
210210
repos.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 4.2.16 on 2025-08-08 21:56
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("libraries", "0030_commitauthor_user"),
10+
]
11+
12+
operations = [
13+
migrations.RemoveField(
14+
model_name="library",
15+
name="active_development",
16+
),
17+
]

libraries/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ class Library(models.Model):
192192
cpp_standard_minimum = models.CharField(
193193
max_length=50, blank=True, null=True
194194
) # deprecated for LibraryVersion.cpp_standard_minimum
195-
active_development = models.BooleanField(default=True, db_index=True)
196195
categories = models.ManyToManyField(Category, related_name="libraries")
197196

198197
authors = models.ManyToManyField("users.User", related_name="authors")

versions/tasks.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,19 @@ def skip_library_version(library_slug, version_slug):
244244
return False
245245

246246

247+
@app.task
248+
def gc_removed_submodules(library_keys: list[str], branch: str) -> None:
249+
"""Remove libraries that are not in the library_keys from the
250+
library_versions list for the current version."""
251+
library_version_keys = LibraryVersion.objects.filter(
252+
version__name=branch
253+
).values_list("library__key", flat=True)
254+
for k in library_version_keys:
255+
if k not in library_keys:
256+
LibraryVersion.objects.filter(version__name=branch, library__key=k).delete()
257+
logger.info(f"{k=} library_version link to {branch=} garbage collected.")
258+
259+
247260
@app.task
248261
def import_library_versions(version_name, token=None, version_type="tag"):
249262
"""For a specific version, imports all LibraryVersions using GitHub data"""
@@ -280,6 +293,7 @@ def import_library_versions(version_name, token=None, version_type="tag"):
280293

281294
# For each gitmodule, gets its libraries.json file and save the libraries
282295
# to the version
296+
library_keys = []
283297
for gitmodule in gitmodules:
284298
library_name = gitmodule["module"]
285299
if library_name in updater.skip_modules:
@@ -336,6 +350,9 @@ def import_library_versions(version_name, token=None, version_type="tag"):
336350
for lib_data in parsed_libraries:
337351
if lib_data["key"] in updater.skip_libraries:
338352
continue
353+
# tracking this 'key' because the gitmodule name doesn't directly match,
354+
# e.g. interval in gitmodule, numericinterval in db/here
355+
library_keys.append(lib_data["key"])
339356

340357
# Handle exceptions based on version and library key
341358
exceptions = LIBRARY_KEY_EXCEPTIONS.get(lib_data["key"], [])
@@ -371,6 +388,12 @@ def import_library_versions(version_name, token=None, version_type="tag"):
371388
library.github_url = github_data.get("html_url", "")
372389
library.save()
373390

391+
# For any libraries no longer in gitmodules we want to remove master and develop
392+
# references from the library_versions list.
393+
if version_name in ["master", "develop"]:
394+
logger.info("Triggering removed submodules garbage collection")
395+
gc_removed_submodules.delay(library_keys, version_name)
396+
374397
# Retrieve and store the docs url for each library-version in this release
375398
get_and_store_library_version_documentation_urls_for_version.delay(version.pk)
376399

0 commit comments

Comments
 (0)