Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbasti committed Jan 24, 2025
1 parent f3a250d commit 62f766b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
10 changes: 1 addition & 9 deletions Src/WitsmlExplorer.Api/Services/LogObjectService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,20 +367,12 @@ private async Task<WitsmlLog> LoadDataRecursive(List<string> mnemonics, WitsmlLo
{
await using LogDataReader logDataReader = new(_witsmlClient, log, new List<string>(mnemonics), null, startIndex, endIndex);
WitsmlLogData logData = await logDataReader.GetNextBatch(cancellationToken);
if (!startIndex.GetValueAsString().Equals(log.StartDateTimeIndex))
{
log.StartDateTimeIndex = startIndex.GetValueAsString();
}
if (!endIndex.GetValueAsString().Equals(log.EndDateTimeIndex))
{
log.EndDateTimeIndex = endIndex.GetValueAsString();
}
var allLogData = logData;
while (logData != null)
{
if (progressReporter != null)
{
double progress = LogWorkerTools.CalculateProgressBasedOnIndex(log, logData);
double progress = LogWorkerTools.CalculateProgressBasedOnIndex(log, logData, startIndex, endIndex);
progressReporter.Report(progress);
}
logData = await logDataReader.GetNextBatch(cancellationToken);
Expand Down
4 changes: 2 additions & 2 deletions Src/WitsmlExplorer.Api/Workers/DownloadLogDataWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public DownloadLogDataWorker(
var logData = await _logObjectService.ReadLogData(job.LogReference.WellUid, job.LogReference.WellboreUid, job.LogReference.Uid, job.Mnemonics.ToList(), job.StartIndexIsInclusive, job.LogReference.StartIndex, job.LogReference.EndIndex, true, cancellationToken, progressReporter);
if (logData.CurveSpecifications == null)
{
var message = "DownloadLogDataJob failed. Start or end indexes are out of range.";
var message = "DownloadLogDataJob failed. No data found in the given range.";
Logger.LogError(message);
return (new WorkerResult(GetTargetWitsmlClientOrThrow().GetServerHostname(), false, message, message), null);
return (new WorkerResult(GetTargetWitsmlClientOrThrow().GetServerHostname(), false, message, message, jobId:job.JobInfo.Id), null);
}

return (job.ExportToLas)
Expand Down
11 changes: 10 additions & 1 deletion Src/WitsmlExplorer.Api/Workers/Tools/LogWorkerTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static async Task<WitsmlLogData> GetLogDataForCurve(IWitsmlClient witsmlC
};
}

public static double CalculateProgressBasedOnIndex(WitsmlLog log, WitsmlLogData currentData)
public static double CalculateProgressBasedOnIndex(WitsmlLog log, WitsmlLogData currentData, CurveIndex start = null, CurveIndex end = null)
{
string index = currentData.Data.LastOrDefault()?.Data.Split(CommonConstants.DataSeparator).FirstOrDefault();
if (index == null) return 0;
Expand All @@ -77,6 +77,15 @@ public static double CalculateProgressBasedOnIndex(WitsmlLog log, WitsmlLogData
{
string startIndex = log.StartDateTimeIndex;
string endIndex = log.EndDateTimeIndex;
if (start != null && !start.GetValueAsString().Equals(log.StartDateTimeIndex))
{
startIndex = start.GetValueAsString();
}
if (end != null && !end.GetValueAsString().Equals(log.EndDateTimeIndex))
{
endIndex = end.GetValueAsString();
}

return (DateTime.Parse(index) - DateTime.Parse(startIndex)).TotalMilliseconds / (DateTime.Parse(endIndex) - DateTime.Parse(startIndex)).TotalMilliseconds;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,8 @@ const DownloadOptionsSelectionModal = (

const outOfRange =
new Date(startIndex).getTime() - new Date(log.startIndex).getTime() < 0 ||
new Date(endIndex).getTime() - new Date(log.endIndex).getTime() > 0
? true
: false;
new Date(endIndex).getTime() - new Date(log.endIndex).getTime() > 0;

return (
<ConfirmModal
heading={`Download log data for ${props.mnemonics.length} mnemonics`}
Expand Down Expand Up @@ -302,7 +301,7 @@ const DownloadOptionsSelectionModal = (
(selectedDownloadOption === DownloadOptions.All ||
selectedDownloadOption === DownloadOptions.SelectedRange) && (
<WarningBar
message={`Selected start and end dates are out of log range. Available range is between ${startIndex} and ${startIndex}`}
message={`Selected start and end dates are out of log range. Available range is between ${log.startIndex} and ${log.endIndex}`}
/>
)}
{isTimeLog && selectedDownloadOption === DownloadOptions.All && (
Expand Down

0 comments on commit 62f766b

Please sign in to comment.