Skip to content

Commit

Permalink
Merge pull request #12 from jl94x4/beta
Browse files Browse the repository at this point in the history
Version 1.13
  • Loading branch information
jl94x4 authored Nov 1, 2024
2 parents befafbc + 2db45c5 commit a739113
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

21 changes: 21 additions & 0 deletions ColleXions.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,27 @@ def filter_collections(config, all_collections, special_collections, collection_
logging.info(f"Selected collection '{selected_collection.title}' from category '{category}'")

logging.info(f"Final collections to pin for {library_name}: {[c.title for c in collections_to_pin]}")
today = datetime.now().date()
active_special_collections = []
for collection in config['special_collections']:
start_date = datetime.strptime(collection['start_date'], '%m-%d').date().replace(year=today.year)
end_date = datetime.strptime(collection['end_date'], '%m-%d').date().replace(year=today.year)
if start_date <= today <= end_date:
active_special_collections.extend(collection['collection_names'])
collections_to_pin = [c for c in all_collections if c.title in active_special_collections]
remaining_slots = collection_limit - len(collections_to_pin)
if remaining_slots > 0:
category_collections = []
for category in config.get('categories', []):
category_collections.extend([c for c in all_collections if c.title == category])
category_collections = category_collections[:remaining_slots]
collections_to_pin.extend(category_collections)
remaining_slots -= len(category_collections)
if remaining_slots > 0:
eligible_regular_collections = [c for c in all_collections if c.title not in exclusion_set and c not in collections_to_pin]
random.shuffle(eligible_regular_collections)
collections_to_pin.extend(eligible_regular_collections[:remaining_slots])
logging.info(f"Final prioritized collections to pin for {library_name}: {[c.title for c in collections_to_pin]}")
return collections_to_pin


Expand Down
2 changes: 0 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
"Category 4": [
"Inclusion 7",
"Inclusion 8"
],

]
}
},
Expand Down

0 comments on commit a739113

Please sign in to comment.