FileMetadataRepository¶
Repository responsible for storing and querying LASCO metadata.
Responsibilities¶
- Persist metadata records
- Query metadata by observation/downlink windows
- Support idempotent discovery
- Support hash-based lookups
API Reference¶
backend.database.repositories.file_metadata_repository.FileMetadataRepository ¶
This class is for file_metadata table required to keep a log
of file metadata, useful beforehand while retrieving the raw data.
bulk_create_metadata ¶
bulk_create_metadata(files)
Inserts multiple file metadata records in a single batch operation.
This method is intended for high-throughput discovery workflows where metadata for many files is parsed together and persisted efficiently. Duplicate records (based on primary/unique constraints) are ignored.
:param files: List of FileMetadata domain entities to insert. :return: Number of rows successfully inserted.
create_indexes_sql
classmethod
¶
create_indexes_sql()
Query to create index for file_metadata table
for faster accessbility.
create_metadata ¶
create_metadata(raw_file_name, raw_file_hash, datetime_of_observation, last_modified_utc, instrument, exposure_time, width, height, roll)
creates the file metadata to a row in the table
:param raw_file_name: raw file name, acts as primary key :param raw_file_hash: hash value of unprocessed file :param datetime_of_observation: date time of observation :param last_modified_utc: date time when file got available :param instrument: instrument used to capture the file :param exposure_time: exposure time in seconds :param width: width in pixels :param height: height in pixels :param roll: frame roll if any :return: Returns True only if the number of created rows is 1
create_table_sql
classmethod
¶
create_table_sql()
Query to create file_metadata table.
timestamps are stored as ISO-8601 UTC strings
delete_metadata ¶
delete_metadata(file)
Deletes metadata entry for a file
:param file: file domain entity :return : returns boolean value, True when deletion happened
exists_by_filename ¶
exists_by_filename(raw_file_name)
Checks if metadata entry exists
:param raw_file_name: raw file name :return: True if row exists
exists_by_hash ¶
exists_by_hash(raw_file_hash)
Checks if a metadata entry exists for a given raw file hash.
Useful for idempotency checks and preventing duplicate ingestion into downstream processing stages.
:param raw_file_hash: Hash value of raw file :return: returns True if metadata exists
get_by_hash ¶
get_by_hash(raw_file_hash)
Fetch metadata using raw file hash.
Useful when processing pipeline operates on hash identity and metadata needs to be retrieved without relying on filename.
:param raw_file_hash: Hash value of raw file :return: FileMetadata domain object if found
get_latest_last_modified ¶
get_latest_last_modified(instrument)
Fetch latest last modified for given instrument.
:param instrument: Instrument enum :return: ISO datetime or None if no records exist
get_metadata_by_observation ¶
get_metadata_by_observation(instrument, observation_start_utc, observation_end_utc)
Fetch metadata for a specific instrument within a observation time range
:param instrument: instrument name :param observation_start_utc: start datetime (UTC format) :param observation_end_utc: end datetime (UTC format) :return: list of FileMetadata objects
get_metadata_by_slot ¶
get_metadata_by_slot(instrument, downlink_start_utc, downlink_end_utc)
Fetch metadata for a specific instrument within a time range
:param instrument: instrument name :param downlink_start_utc: start datetime (UTC) :param downlink_end_utc: end datetime (UTC) :return: list of FileMetadata objects
get_missing_hash_files ¶
get_missing_hash_files(instrument, limit=10)
Fetch metadata records where raw file hash is not yet populated.
Useful for identifying files that require hash computation after discovery/download
:param instrument: instrument name to filter by :param limit: Optional maximum number of records to return :return: returns a List of FileMetadata domain objects
read_metadata ¶
read_metadata(raw_file_name)
Fetch metadata using raw file name
:param raw_file_name: raw file name primary key :return: returns complete file metadata
update_hash ¶
update_hash(file)
Updates hash value of raw file
:param file: FileMetadata domain entity containing updated hash :return: True only if exactly one row was updated