boolinate video/audio
This commit is contained in:
parent
ed735e17be
commit
ee7a4f178c
3 changed files with 32 additions and 29 deletions
|
@ -456,11 +456,11 @@ class Image
|
|||
"id" => $this->id,
|
||||
"width" => $this->width ?? 0,
|
||||
"height" => $this->height ?? 0,
|
||||
"lossless" => $database->scoresql_value_prepare($this->lossless),
|
||||
"video" => $database->scoresql_value_prepare($this->video),
|
||||
"lossless" => $this->lossless,
|
||||
"video" => $this->video,
|
||||
"video_codec" => $this->video_codec,
|
||||
"image" => $this->image,
|
||||
"audio" => $database->scoresql_value_prepare($this->audio),
|
||||
"audio" => $this->audio,
|
||||
"length" => $this->length
|
||||
]
|
||||
);
|
||||
|
|
|
@ -248,7 +248,7 @@ class Media extends Extension
|
|||
if ($field==="unknown") {
|
||||
$event->add_querylet(new Querylet("video IS NULL OR audio IS NULL OR image IS NULL"));
|
||||
} else {
|
||||
$event->add_querylet(new Querylet($database->scoreql_to_sql("$field = SCORE_BOOL_Y")));
|
||||
$event->add_querylet(new Querylet("$field = :true", ["true"=>true]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,15 +136,9 @@ class Upgrade extends Extension
|
|||
|
||||
if ($this->get_version("db_version") < 17) {
|
||||
log_info("upgrade", "Adding media information columns to images table");
|
||||
$database->execute($database->scoreql_to_sql(
|
||||
"ALTER TABLE images ADD COLUMN lossless SCORE_BOOL NULL"
|
||||
));
|
||||
$database->execute($database->scoreql_to_sql(
|
||||
"ALTER TABLE images ADD COLUMN video SCORE_BOOL NULL"
|
||||
));
|
||||
$database->execute($database->scoreql_to_sql(
|
||||
"ALTER TABLE images ADD COLUMN audio SCORE_BOOL NULL"
|
||||
));
|
||||
$database->execute("ALTER TABLE images ADD COLUMN lossless BOOLEAN NULL");
|
||||
$database->execute("ALTER TABLE images ADD COLUMN video BOOLEAN NULL");
|
||||
$database->execute("ALTER TABLE images ADD COLUMN audio BOOLEAN NULL");
|
||||
$database->execute("ALTER TABLE images ADD COLUMN length INTEGER NULL ");
|
||||
|
||||
log_info("upgrade", "Setting indexes for media columns");
|
||||
|
@ -170,22 +164,7 @@ class Upgrade extends Extension
|
|||
$this->set_version("db_version", 17);
|
||||
}
|
||||
|
||||
if ($this->get_version("db_version") < 18) {
|
||||
log_info("upgrade", "Setting predictable media values for known file types");
|
||||
if ($database->transaction) {
|
||||
// Each of these commands could hit a lot of data, combining
|
||||
// them into one big transaction would not be a good idea.
|
||||
$database->commit();
|
||||
}
|
||||
$database->execute($database->scoreql_to_sql("UPDATE images SET lossless = SCORE_BOOL_Y, video = SCORE_BOOL_Y WHERE ext IN ('swf')"));
|
||||
$database->execute($database->scoreql_to_sql("UPDATE images SET lossless = SCORE_BOOL_N, video = SCORE_BOOL_N, audio = SCORE_BOOL_Y WHERE ext IN ('mp3')"));
|
||||
$database->execute($database->scoreql_to_sql("UPDATE images SET lossless = SCORE_BOOL_N, video = SCORE_BOOL_N, audio = SCORE_BOOL_N WHERE ext IN ('jpg','jpeg')"));
|
||||
$database->execute($database->scoreql_to_sql("UPDATE images SET lossless = SCORE_BOOL_Y, video = SCORE_BOOL_N, audio = SCORE_BOOL_N WHERE ext IN ('ico','ani','cur','png','svg')"));
|
||||
$database->execute($database->scoreql_to_sql("UPDATE images SET lossless = SCORE_BOOL_Y, audio = SCORE_BOOL_N WHERE ext IN ('gif')"));
|
||||
$database->execute($database->scoreql_to_sql("UPDATE images SET audio = SCORE_BOOL_N WHERE ext IN ('webp')"));
|
||||
$database->execute($database->scoreql_to_sql("UPDATE images SET lossless = SCORE_BOOL_N, video = SCORE_BOOL_Y WHERE ext IN ('flv','mp4','m4v','ogv','webm')"));
|
||||
$this->set_version("db_version", 18);
|
||||
}
|
||||
// 18 was populating data using an out of date format
|
||||
|
||||
if ($this->get_version("db_version") < 19) {
|
||||
log_info("upgrade", "Adding MIME type column");
|
||||
|
@ -197,6 +176,30 @@ class Upgrade extends Extension
|
|||
|
||||
$this->set_version("db_version", 19);
|
||||
}
|
||||
|
||||
if ($this->get_version("db_version") < 20) {
|
||||
$database->standardise_boolean("images", "lossless");
|
||||
$database->standardise_boolean("images", "video");
|
||||
$database->standardise_boolean("images", "audio");
|
||||
$this->set_version("db_version", 20);
|
||||
}
|
||||
|
||||
if ($this->get_version("db_version") < 21) {
|
||||
log_info("upgrade", "Setting predictable media values for known file types");
|
||||
if ($database->transaction) {
|
||||
// Each of these commands could hit a lot of data, combining
|
||||
// them into one big transaction would not be a good idea.
|
||||
$database->commit();
|
||||
}
|
||||
$database->execute("UPDATE images SET lossless = :t, video = :t WHERE ext IN ('swf')", ["t"=>true]);
|
||||
$database->execute("UPDATE images SET lossless = :f, video = :f, audio = :t WHERE ext IN ('mp3')", ["t"=>true, "f"=>false]);
|
||||
$database->execute("UPDATE images SET lossless = :f, video = :f, audio = :f WHERE ext IN ('jpg','jpeg')", ["f"=>false]);
|
||||
$database->execute("UPDATE images SET lossless = :t, video = :f, audio = :f WHERE ext IN ('ico','ani','cur','png','svg')", ["t"=>true, "f"=>false]);
|
||||
$database->execute("UPDATE images SET lossless = :t, audio = :f WHERE ext IN ('gif')", ["t"=>true, "f"=>false]);
|
||||
$database->execute("UPDATE images SET audio = :f WHERE ext IN ('webp')", ["f"=>false]);
|
||||
$database->execute("UPDATE images SET lossless = :f, video = :t WHERE ext IN ('flv','mp4','m4v','ogv','webm')", ["t"=>true, "f"=>false]);
|
||||
$this->set_version("db_version", 21);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_priority(): int
|
||||
|
|
Reference in a new issue