Skip to content

Commit f46c6e7

Browse files
Merge pull request #77 from MikroElektronika/improvement/restructure
Added option to reindex only current daily update needed stuff
2 parents 08effc2 + 8f0c4d8 commit f46c6e7

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

.github/workflows/boardCardReleaseTest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
MIKROE_NECTO_AWS: ${{ secrets.MIKROE_NECTO_AWS }}
9595
run: |
9696
echo "Indexing to Test."
97-
python -u scripts/index.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} ${{ steps.changelog_update.outputs.sdk_tag_name }} ${{ secrets.ES_INDEX_TEST }} "False"
97+
python -u scripts/index.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} ${{ steps.changelog_update.outputs.sdk_tag_name }} ${{ secrets.ES_INDEX_TEST }} "False" "--board_card_only" "True"
9898
9999
- name: Trigger database update in Core repo
100100
run: |

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ output
44
__pycache__
55
*.7z
66
tmp
7+
install
8+
.cache
9+
.meproject
10+
build*
11+
.clangd
12+
compile_commands.json
13+
settings.json

scripts/index.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def fetch_current_indexed_version(es : Elasticsearch, index_name, package_name):
187187
return None
188188

189189
# 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):
191191
# Iterate over each asset in the release and previous release
192192
metadata_content = []
193193
for each_release_details in release_details:
@@ -243,6 +243,15 @@ def index_release_to_elasticsearch(es : Elasticsearch, index_name, release_detai
243243
name_without_extension = os.path.splitext(os.path.basename(asset['name']))[0]
244244
package_id = name_without_extension
245245

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+
246255
# Increase bar value
247256
bar.text(name_without_extension)
248257
bar()
@@ -486,6 +495,7 @@ def str2bool(v):
486495
parser.add_argument("release_version", help="Selected release version to index", type=str)
487496
parser.add_argument("select_index", help="Provided index name")
488497
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)
489499
args = parser.parse_args()
490500

491501
# Elasticsearch instance used for indexing
@@ -507,7 +517,7 @@ def str2bool(v):
507517
index_release_to_elasticsearch(
508518
es, args.select_index,
509519
fetch_release_details(args.repo, args.token, args.release_version),
510-
args.token
520+
args.token, args.board_card_only
511521
)
512522

513523
# And then promote to latest if requested

0 commit comments

Comments
 (0)