mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-21 02:33:50 +00:00
[editor] Automatically create/update check_date
Signed-off-by: matheusgomesms <matheusgomesms@noreply.codeberg.org>
This commit is contained in:
@@ -862,24 +862,8 @@ void EditableMapObject::LogDiffInJournal(EditableMapObject const & unedited_emo)
|
||||
{
|
||||
LOG(LDEBUG, ("Executing LogDiffInJournal"));
|
||||
|
||||
// Auto-fill check_date
|
||||
if (ftypes::IsCheckDateChecker::Instance()(GetTypes()))
|
||||
{
|
||||
std::string const currentDate = GetCurrentDate();
|
||||
|
||||
// Always update check_date
|
||||
SetMetadata(feature::Metadata::FMD_CHECK_DATE, currentDate);
|
||||
|
||||
// Update check_date:opening_hours if Opening Hours changed
|
||||
std::string_view const newOH = GetMetadata(feature::Metadata::FMD_OPEN_HOURS);
|
||||
std::string_view const oldOH = unedited_emo.GetMetadata(feature::Metadata::FMD_OPEN_HOURS);
|
||||
|
||||
// If new OH exists and is different from old (or old was empty), update the date.
|
||||
if (!newOH.empty() && newOH != oldOH)
|
||||
{
|
||||
SetMetadata(feature::Metadata::FMD_CHECK_DATE_OPEN_HOURS, currentDate);
|
||||
}
|
||||
}
|
||||
// Capture the initial size of the journal to detect if changes occur later
|
||||
auto const initialJournalSize = m_journal.GetJournal().size();
|
||||
|
||||
// Name
|
||||
for (StringUtf8Multilang::Lang language : StringUtf8Multilang::GetSupportedLanguages())
|
||||
@@ -971,6 +955,39 @@ void EditableMapObject::LogDiffInJournal(EditableMapObject const & unedited_emo)
|
||||
std::tie(key, old_value, new_value) = kvdiff;
|
||||
m_journal.AddTagChange(key, old_value, new_value);
|
||||
}
|
||||
|
||||
// check_date logic
|
||||
// Check if any changes were detected (Journal grew)
|
||||
if (m_journal.GetJournal().size() > initialJournalSize)
|
||||
{
|
||||
// Auto-fill check_date only if other changes exist
|
||||
if (ftypes::IsCheckDateChecker::Instance()(GetTypes()))
|
||||
{
|
||||
std::string const currentDate = GetCurrentDate();
|
||||
|
||||
// Update check_date
|
||||
std::string_view const oldCheckDate = unedited_emo.GetMetadata(feature::Metadata::FMD_CHECK_DATE);
|
||||
if (oldCheckDate != currentDate)
|
||||
{
|
||||
SetMetadata(feature::Metadata::FMD_CHECK_DATE, currentDate);
|
||||
m_journal.AddTagChange("check_date", std::string(oldCheckDate), currentDate);
|
||||
}
|
||||
|
||||
// Update check_date:opening_hours if Opening Hours changed
|
||||
std::string_view const newOH = GetMetadata(feature::Metadata::FMD_OPEN_HOURS);
|
||||
std::string_view const oldOH = unedited_emo.GetMetadata(feature::Metadata::FMD_OPEN_HOURS);
|
||||
|
||||
if (!newOH.empty() && newOH != oldOH)
|
||||
{
|
||||
std::string_view const oldOHDate = unedited_emo.GetMetadata(feature::Metadata::FMD_CHECK_DATE_OPEN_HOURS);
|
||||
if (oldOHDate != currentDate)
|
||||
{
|
||||
SetMetadata(feature::Metadata::FMD_CHECK_DATE_OPEN_HOURS, currentDate);
|
||||
m_journal.AddTagChange("check_date:opening_hours", std::string(oldOHDate), currentDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditableMapObject::ApplyBusinessReplacement(uint32_t new_type)
|
||||
|
||||
Reference in New Issue
Block a user