Commit 3f819bbd authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

MediaGroup: Fix indentation

parent 30305bb9
Pipeline #143575 passed with stages
in 4 minutes and 59 seconds
......@@ -906,89 +906,89 @@ std::string MediaGroup::trigger( MediaGroup::Triggers t, uint32_t dbModel )
* - We now only monitor internal media
* - Fix invalid decrement of nb_audio
*/
return "CREATE TRIGGER " + triggerName( t, dbModel ) +
" AFTER UPDATE OF type, group_id ON " + Media::Table::Name +
" WHEN (IFNULL(old.group_id, 0) != IFNULL(new.group_id, 0) OR"
" old.type != new.type) AND"
" new.import_type = " +
std::to_string(static_cast<std::underlying_type_t<Media::ImportType>>(
Media::ImportType::Internal ) ) +
" BEGIN"
// Handle increment
" UPDATE " + Table::Name + " SET"
" nb_video = nb_video + "
"(CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Video ) ) +
" THEN 1 ELSE 0 END),"
" nb_present_video = nb_present_video + "
"(CASE new.is_present WHEN 0 THEN 0 ELSE "
return "CREATE TRIGGER " + triggerName( t, dbModel ) +
" AFTER UPDATE OF type, group_id ON " + Media::Table::Name +
" WHEN (IFNULL(old.group_id, 0) != IFNULL(new.group_id, 0) OR"
" old.type != new.type) AND"
" new.import_type = " +
std::to_string(static_cast<std::underlying_type_t<Media::ImportType>>(
Media::ImportType::Internal ) ) +
" BEGIN"
// Handle increment
" UPDATE " + Table::Name + " SET"
" nb_video = nb_video + "
"(CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Video ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_audio = nb_audio + "
"(CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Audio ) ) +
" THEN 1 ELSE 0 END),"
" nb_present_audio = nb_present_audio + "
"(CASE new.is_present WHEN 0 THEN 0 ELSE "
" THEN 1 ELSE 0 END),"
" nb_present_video = nb_present_video + "
"(CASE new.is_present WHEN 0 THEN 0 ELSE "
"(CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Video ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_audio = nb_audio + "
"(CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Audio ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_unknown = nb_unknown + "
"(CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Unknown ) ) +
" THEN 1 ELSE 0 END),"
" nb_present_unknown = nb_present_unknown + "
"(CASE new.is_present WHEN 0 THEN 0 ELSE "
" THEN 1 ELSE 0 END),"
" nb_present_audio = nb_present_audio + "
"(CASE new.is_present WHEN 0 THEN 0 ELSE "
"(CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Audio ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_unknown = nb_unknown + "
"(CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Unknown ) ) +
" THEN 1 ELSE 0 END) END),"
" last_modification_date = strftime('%s')"
" WHERE new.group_id IS NOT NULL AND id_group = new.group_id;"
// Handle decrement
" UPDATE " + Table::Name + " SET"
" nb_present_video = nb_present_video - "
"(CASE old.is_present WHEN 0 THEN 0 ELSE "
" THEN 1 ELSE 0 END),"
" nb_present_unknown = nb_present_unknown + "
"(CASE new.is_present WHEN 0 THEN 0 ELSE "
"(CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Unknown ) ) +
" THEN 1 ELSE 0 END) END),"
" last_modification_date = strftime('%s')"
" WHERE new.group_id IS NOT NULL AND id_group = new.group_id;"
// Handle decrement
" UPDATE " + Table::Name + " SET"
" nb_present_video = nb_present_video - "
"(CASE old.is_present WHEN 0 THEN 0 ELSE "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Video ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_video = nb_video - "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Video ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_video = nb_video - "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Video ) ) +
" THEN 1 ELSE 0 END),"
" nb_present_audio = nb_present_audio - "
"(CASE old.is_present WHEN 0 THEN 0 ELSE "
" THEN 1 ELSE 0 END),"
" nb_present_audio = nb_present_audio - "
"(CASE old.is_present WHEN 0 THEN 0 ELSE "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Audio ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_audio = nb_audio - "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Audio ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_audio = nb_audio - "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Audio ) ) +
" THEN 1 ELSE 0 END),"
" nb_present_unknown = nb_present_unknown - "
"(CASE old.is_present WHEN 0 THEN 0 ELSE "
" THEN 1 ELSE 0 END),"
" nb_present_unknown = nb_present_unknown - "
"(CASE old.is_present WHEN 0 THEN 0 ELSE "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Unknown ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_unknown = nb_unknown - "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Unknown ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_unknown = nb_unknown - "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Unknown ) ) +
" THEN 1 ELSE 0 END),"
" last_modification_date = strftime('%s')"
" WHERE old.group_id IS NOT NULL AND id_group = old.group_id;"
" END";
" THEN 1 ELSE 0 END),"
" last_modification_date = strftime('%s')"
" WHERE old.group_id IS NOT NULL AND id_group = old.group_id;"
" END";
}
/**
* Change since V31:
......@@ -1115,47 +1115,47 @@ std::string MediaGroup::trigger( MediaGroup::Triggers t, uint32_t dbModel )
}
if ( dbModel < 33 )
{
return "CREATE TRIGGER " + triggerName( t, dbModel ) +
" AFTER DELETE ON " + Media::Table::Name +
" WHEN old.group_id IS NOT NULL"
" BEGIN"
" UPDATE " + Table::Name + " SET"
" nb_present_video = nb_present_video - "
"(CASE old.is_present WHEN 0 THEN 0 ELSE "
return "CREATE TRIGGER " + triggerName( t, dbModel ) +
" AFTER DELETE ON " + Media::Table::Name +
" WHEN old.group_id IS NOT NULL"
" BEGIN"
" UPDATE " + Table::Name + " SET"
" nb_present_video = nb_present_video - "
"(CASE old.is_present WHEN 0 THEN 0 ELSE "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Video ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_video = nb_video - "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Video ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_video = nb_video - "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Video ) ) +
" THEN 1 ELSE 0 END),"
" nb_present_audio = nb_present_audio - "
"(CASE old.is_present WHEN 0 THEN 0 ELSE "
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Video ) ) +
" THEN 1 ELSE 0 END),"
" nb_present_audio = nb_present_audio - "
"(CASE old.is_present WHEN 0 THEN 0 ELSE "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Audio ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_audio = nb_audio - "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Audio ) ) +
" THEN 1 ELSE 0 END) END),"
" nb_audio = nb_audio - "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Audio ) ) +
" THEN 1 ELSE 0 END),"
" nb_present_unknown = nb_present_unknown - "
"(CASE old.is_present WHEN 0 THEN 0 ELSE "
" THEN 1 ELSE 0 END),"
" nb_present_unknown = nb_present_unknown - "
"(CASE old.is_present WHEN 0 THEN 0 ELSE "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Unknown) ) +
" THEN 1 ELSE 0 END) END),"
" nb_unknown = nb_unknown - "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Unknown) ) +
" THEN 1 ELSE 0 END) END),"
" nb_unknown = nb_unknown - "
"(CASE old.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Unknown ) ) +
" THEN 1 ELSE 0 END),"
" last_modification_date = strftime('%s')"
" WHERE id_group = old.group_id;"
" END";
IMedia::Type::Unknown ) ) +
" THEN 1 ELSE 0 END),"
" last_modification_date = strftime('%s')"
" WHERE id_group = old.group_id;"
" END";
}
return "CREATE TRIGGER " + triggerName( t, dbModel ) +
" AFTER DELETE ON " + Media::Table::Name +
......@@ -1327,36 +1327,36 @@ std::string MediaGroup::trigger( MediaGroup::Triggers t, uint32_t dbModel )
}
if ( dbModel < 33 )
{
return "CREATE TRIGGER " + triggerName( t, dbModel ) +
" AFTER UPDATE OF is_present ON " + Media::Table::Name +
" WHEN old.is_present != new.is_present"
" AND new.group_id IS NOT NULL"
" BEGIN"
" UPDATE " + Table::Name + " SET"
/* Compute the increment in 2 steps: first set it to 1 if the
* media type matches the targeted field, then negate it if
* the media went missing
*/
" nb_present_video = nb_present_video + "
" (CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Video ) ) +
" THEN 1 ELSE 0 END) *"
" (CASE new.is_present WHEN 0 THEN -1 ELSE 1 END),"
" nb_present_audio = nb_present_audio + "
" (CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Audio ) ) +
" THEN 1 ELSE 0 END) *"
" (CASE new.is_present WHEN 0 THEN -1 ELSE 1 END),"
" nb_present_unknown = nb_present_unknown + "
" (CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Unknown ) ) +
" THEN 1 ELSE 0 END) *"
" (CASE new.is_present WHEN 0 THEN -1 ELSE 1 END)"
" WHERE id_group = new.group_id;"
" END";
return "CREATE TRIGGER " + triggerName( t, dbModel ) +
" AFTER UPDATE OF is_present ON " + Media::Table::Name +
" WHEN old.is_present != new.is_present"
" AND new.group_id IS NOT NULL"
" BEGIN"
" UPDATE " + Table::Name + " SET"
/* Compute the increment in 2 steps: first set it to 1 if the
* media type matches the targeted field, then negate it if
* the media went missing
*/
" nb_present_video = nb_present_video + "
" (CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Video ) ) +
" THEN 1 ELSE 0 END) *"
" (CASE new.is_present WHEN 0 THEN -1 ELSE 1 END),"
" nb_present_audio = nb_present_audio + "
" (CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Audio ) ) +
" THEN 1 ELSE 0 END) *"
" (CASE new.is_present WHEN 0 THEN -1 ELSE 1 END),"
" nb_present_unknown = nb_present_unknown + "
" (CASE new.type WHEN " +
std::to_string( static_cast<std::underlying_type_t<IMedia::Type>>(
IMedia::Type::Unknown ) ) +
" THEN 1 ELSE 0 END) *"
" (CASE new.is_present WHEN 0 THEN -1 ELSE 1 END)"
" WHERE id_group = new.group_id;"
" END";
}
return "CREATE TRIGGER " + triggerName( t, dbModel ) +
" AFTER UPDATE OF is_present ON " + Media::Table::Name +
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment