-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #282 from dr-rodriguez/Versions_table
Adding a Versions table; part of #263
- Loading branch information
Showing
5 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"version": "2022.1", | ||
"start_date": "2020-06-22", | ||
"end_date": "2022-08-23", | ||
"description": "Initial release" | ||
}, | ||
{ | ||
"version": "latest", | ||
"start_date": "2022-08-23", | ||
"end_date": null, | ||
"description": "Version in development" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Script to show how to update the version number | ||
|
||
import logging | ||
from astrodbkit2 import REFERENCE_TABLES | ||
from scripts.ingests.utils import logger, load_simpledb | ||
|
||
logger.setLevel(logging.INFO) | ||
|
||
db = load_simpledb('SIMPLE.db', recreatedb=True, reference_tables=REFERENCE_TABLES+['Versions']) | ||
|
||
# Check all versions | ||
print(db.query(db.Versions).table()) | ||
|
||
# Add new version, add new entries as appropriate | ||
# Note that start_date and end_date are strings of the date in format YYYY-MM-DD | ||
data = [{'version': '2022.1', 'start_date': '2020-06-22', | ||
'end_date': '2022-08-23', 'description': 'Initial release'}] | ||
db.Versions.insert().execute(data) | ||
|
||
# Fetch data of latest release | ||
latest_date = db.query(db.Versions.c.end_date).order_by(db.Versions.c.end_date.desc()).limit(1).table() | ||
latest_date = latest_date['end_date'].value[0] | ||
|
||
latest = db.query(db.Versions).filter(db.Versions.c.version == 'latest').count() | ||
if latest == 0: | ||
# Add latest if not present | ||
data = [{'version': 'latest', 'start_date': latest_date, 'description': 'Version in development'}] | ||
db.Versions.insert().execute(data) | ||
else: | ||
# Update if present | ||
db.Versions.update().where(db.Versions.c.version == 'latest').values(start_date=latest_date).execute() | ||
|
||
# Save the database | ||
db.save_database('data/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
|
||
# Used to overwrite AstrodbKit2 reference tables defaults | ||
REFERENCE_TABLES = ['Publications', 'Telescopes', 'Instruments', 'Modes', 'PhotometryFilters'] | ||
REFERENCE_TABLES = ['Publications', 'Telescopes', 'Instruments', 'Modes', 'PhotometryFilters', 'Versions'] |