update-assets-set-local-date-time-for-three-and-seven
This commit is contained in:
@ -47,4 +47,8 @@ public class AssetsController(AssetService assetService) : ControllerBase {
|
|||||||
public IActionResult SetDigiKam4ArchiveImmich(Guid ownerId) =>
|
public IActionResult SetDigiKam4ArchiveImmich(Guid ownerId) =>
|
||||||
Ok(_AssetService.SetDigiKam4ArchiveImmich(ownerId));
|
Ok(_AssetService.SetDigiKam4ArchiveImmich(ownerId));
|
||||||
|
|
||||||
|
[HttpGet("update-assets-set-local-date-time-for-three-and-seven")]
|
||||||
|
public IActionResult UpdateAssetsSetLocalDateTimeForThreeAndSeven() =>
|
||||||
|
Ok(_AssetService.UpdateAssetsSetLocalDateTimeForThreeAndSeven());
|
||||||
|
|
||||||
}
|
}
|
@ -242,4 +242,13 @@ public class AssetService(ILogger<Program> logger, AppSettings appSettings) {
|
|||||||
return results?.AsReadOnly();
|
return results?.AsReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReadOnlyCollection<int>? UpdateAssetsSetLocalDateTimeForThreeAndSeven() {
|
||||||
|
ReadOnlyCollection<int>? results;
|
||||||
|
NpgsqlParameter[] npgsqlParameters = [];
|
||||||
|
string commandText = CommandText.UpdateAssetsSetLocalDateTimeForThreeAndSeven(_Settings.LowestVersionHistory);
|
||||||
|
int? result = ExecuteNonQuery(_Settings.ConnectionString, commandText, npgsqlParameters.AsReadOnly());
|
||||||
|
results = result is null ? null : new([result.Value]);
|
||||||
|
return results?.AsReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -174,4 +174,22 @@ internal static class CommandText {
|
|||||||
return string.Join(Environment.NewLine, results);
|
return string.Join(Environment.NewLine, results);
|
||||||
} // cSpell:enable
|
} // cSpell:enable
|
||||||
|
|
||||||
|
internal static string UpdateAssetsSetLocalDateTimeForThreeAndSeven(float lowestVersionHistory) { // cSpell:disable
|
||||||
|
List<string> results = [];
|
||||||
|
if (lowestVersionHistory <= 1.129) {
|
||||||
|
results.Add(" UPDATE assets ");
|
||||||
|
} else {
|
||||||
|
results.Add(" UPDATE public.asset ");
|
||||||
|
}
|
||||||
|
results.AddRange([
|
||||||
|
" SET \"localDateTime\" = TIMESTAMPTZ(\"localDateTime\") - INTERVAL '100 years' ",
|
||||||
|
" WHERE \"localDateTime\" > TIMESTAMPTZ '1990-01-01 00:00:00-00' ",
|
||||||
|
" AND ( ",
|
||||||
|
" \"deviceAssetId\" like '%3.%' ",
|
||||||
|
" OR \"deviceAssetId\" like '%7.%' ",
|
||||||
|
" ); ",
|
||||||
|
]);
|
||||||
|
return string.Join(Environment.NewLine, results);
|
||||||
|
} // cSpell:enable
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user