@@ -187,7 +187,7 @@ def fetch_current_indexed_version(es : Elasticsearch, index_name, package_name):
187
187
return None
188
188
189
189
# Function to index release details into Elasticsearch
190
- def index_release_to_elasticsearch (es : Elasticsearch , index_name , release_details , token ):
190
+ def index_release_to_elasticsearch (es : Elasticsearch , index_name , release_details , token , board_card_only = False ):
191
191
# Iterate over each asset in the release and previous release
192
192
metadata_content = []
193
193
for each_release_details in release_details :
@@ -243,6 +243,15 @@ def index_release_to_elasticsearch(es : Elasticsearch, index_name, release_detai
243
243
name_without_extension = os .path .splitext (os .path .basename (asset ['name' ]))[0 ]
244
244
package_id = name_without_extension
245
245
246
+ ## Index only current date assets if board_card_only is True,
247
+ ## but re-index images always!
248
+ if board_card_only and name_without_extension != 'images' :
249
+ asset_date = datetime .strptime (asset ['created_at' ], "%Y-%m-%dT%H:%M:%SZ" )
250
+ if asset_date .date () != datetime .utcnow ().date ():
251
+ logger .info ("Asset %s not indexed" % name_without_extension )
252
+ bar ()
253
+ continue
254
+
246
255
# Increase bar value
247
256
bar .text (name_without_extension )
248
257
bar ()
@@ -486,6 +495,7 @@ def str2bool(v):
486
495
parser .add_argument ("release_version" , help = "Selected release version to index" , type = str )
487
496
parser .add_argument ("select_index" , help = "Provided index name" )
488
497
parser .add_argument ("promote_release_to_latest" , help = "Sets current release as latest" , type = str2bool , default = False )
498
+ parser .add_argument ("--board_card_only" , help = "Will reindex only things needed for current daily update" , type = bool , default = False )
489
499
args = parser .parse_args ()
490
500
491
501
# Elasticsearch instance used for indexing
@@ -507,7 +517,7 @@ def str2bool(v):
507
517
index_release_to_elasticsearch (
508
518
es , args .select_index ,
509
519
fetch_release_details (args .repo , args .token , args .release_version ),
510
- args .token
520
+ args .token , args . board_card_only
511
521
)
512
522
513
523
# And then promote to latest if requested
0 commit comments