Skip to content

Commit

Permalink
Merge pull request mbari-org#243 from MBARIMike/main
Browse files Browse the repository at this point in the history
Allow Mission in .xlsx to include the parent directory or not
  • Loading branch information
MBARIMike authored May 30, 2024
2 parents ff302c1 + 4507519 commit b2c6c1d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
//"args": ["-v", "1", "--skipuntil_regex", "--regex", "MappingAUVOps2018/20180725m1/ZTopo.grd$", "--limit", "2"],
//"args": [ "-v", "2", "--clobber", "--skipuntil_regex", "--regex", "mbsystem/Data/2012/20120103_MB-System_Tutorial_OFG/ProprietaryOFGSampleData/20101127OFGSample/multibeam_hsx"],
//"args": [ "-v", "1", "--clobber", "--noinput", "--skipuntil_regex", "--regex", "MappingAUVOps2014/Sentry_Loihi/2014-glazer/dives/sentry265/multibeam/mbari/ZTopo.grd$", "--limit", "1" ],
//"args": [ "-v", "1", "--skipuntil_regex", "--regex", "2021/20210812m1/ZTopo.grd$", "--limit", "10" ],
"args": [ "-v", "1", "--skipuntil_regex", "--regex", "2021/20210812m1/ZTopo.grd$", "--limit", "10" ],
//"args": [ "-v", "1", "--skipuntil_regex", "--regex", "2023/20230511d1/photogrammetry/ZTopo.grd$", "--limit", "1" ],
//"args": [ "-v", "1", "--skipuntil_regex", "--regex", "2019/20190820m1/ZTopo.grd$", "--limit", "100" ],
//"args": [ "-v", "1", "--skipuntil_regex", "--regex", "2023/20230310m1/ZTopo.grd$", "--limit", "10" ],
Expand Down Expand Up @@ -85,7 +85,7 @@
//"args": ["--spreadsheets", "-v", "1"],
//"args": ["-v", "1", "--last_n_days", "0.5"],
//"args": ["-v", "1", "--spreadsheets", "--parent_dir", "2024", "--append_to_log_file"],
"args": ["-v", "1", "--spreadsheets"],
//"args": ["-v", "1", "--spreadsheets"],
//"args": ["-v", "1", "--compilation", "--last_n_days", "30"],
"justMyCode": false
}
12 changes: 10 additions & 2 deletions smdb/scripts/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ def flush_database(self):
def _exclude_path(self, fp):
for e_path in self.exclude_paths:
if fp.startswith(e_path):
self.logger.info("Excluding file: %s", fp)
self.logger.debug("Excluding file: %s", fp)
return True
return False

Expand Down Expand Up @@ -1173,6 +1173,7 @@ def load_from_grds(self):
miss_count = 0
match_count = 0
miss_loaded = 0
exclude_count = 0
if self.args.last_n_days:
self.logger.info(
"Loading Missions newer than %d days", self.args.last_n_days
Expand All @@ -1193,6 +1194,7 @@ def load_from_grds(self):
self.logger.debug("Skipping until %s", self.args.regex)
continue
if self._exclude_path(fp):
exclude_count += 1
continue
if self.args.last_n_days:
if os.path.getmtime(fp) < time() - self.args.last_n_days * 86400:
Expand Down Expand Up @@ -1264,6 +1266,9 @@ def load_from_grds(self):
"Missions matching regex '%s': %d", self.args.regex, match_count
)
self.logger.info("Count of Missions not excluded: %d", miss_count)
self.logger.info(
"Count of Missions excluded found in exclude.list file: %d", exclude_count
)
self.logger.info("Missions loaded: %d", miss_loaded)


Expand Down Expand Up @@ -1598,7 +1603,10 @@ def update_db_from_df(self, df: pd.DataFrame, parent_dir: str) -> None:
try:
count += 1
# Get the Mission object for this row
mission = Mission.objects.get(name=f"{parent_dir}/{row['Mission']}")
if row["Mission"].startswith(f"{parent_dir}/"):
mission = Mission.objects.get(name=row["Mission"])
else:
mission = Mission.objects.get(name=f"{parent_dir}/{row['Mission']}")
# Update the fields, mapping the column names to the Mission field names
mission.route_file = row["Route"]
mission.region_name = row["Location"]
Expand Down
51 changes: 51 additions & 0 deletions smdb/smdb/templates/smdb_tables2_bootstrap5.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,57 @@
{% load i18n l10n %}
{% block table-wrapper %}
<div class="table-container">
{% block pagination_top %}
<nav aria-label="Table navigation">
<ul class="pagination justify-content-center">
{% if table.page and table.paginator.num_pages > 1 %}
{% if table.page.has_previous %}
{% block pagination_top.previous %}
<li class="previous page-item">
<a href="{% querystring table.prefixed_page_field=table.page.previous_page_number %}" class="page-link">
<span aria-hidden="true">&laquo;</span>
{% trans 'previous' %}
</a>
</li>
{% endblock pagination_top.previous %}
{% endif %}
{% if table.page.has_previous or table.page.has_next %}
{% block pagination_top.range %}
{% for p in table.page|table_page_range:table.paginator %}
<li class="page-item{% if table.page.number == p %} active{% endif %}">
<a class="page-link" {% if p != '...' %}href="{% querystring table.prefixed_page_field=p %}"{% endif %}>
{{ p }}
</a>
</li>
{% endfor %}
{% endblock pagination_top.range %}
{% endif %}
{% if table.page.has_next %}
{% block pagination_top.next %}
<li class="next page-item">
<a href="{% querystring table.prefixed_page_field=table.page.next_page_number %}" class="page-link">
{% trans 'next' %}
<span aria-hidden="true">&raquo;</span>
</a>
</li>
{% endblock pagination_top.next %}
{% endif %}
{% endif %}
<li class="align-items-center">
Show [
<a href="{% querystring "per_page"=1 %}">1</a>
| <a href="{% querystring "per_page"=2 %}">2</a>
| <a href="{% querystring "per_page"=5 %}">5</a>
| <a href="{% querystring "per_page"=10 %}">10</a>
| <a href="{% querystring "per_page"=20 %}">20</a>
| <a href="{% querystring "per_page"=50 %}">50</a>
| <a href="{% querystring "per_page"=500 %}">500</a>
] items
</li>
</ul>
</nav>
{% endblock pagination_top %}

{% block table %}
<table {% render_attrs table.attrs class="table" %}>
{% block table.thead %}
Expand Down

0 comments on commit b2c6c1d

Please sign in to comment.