mirror of https://github.com/calzoneman/sync.git
Fix updated_at in media_metadata_cache
This commit is contained in:
parent
5a386d0f81
commit
83fd8f11b2
|
@ -1,5 +1,4 @@
|
||||||
import { createMySQLDuplicateKeyUpdate } from '../util/on-duplicate-key-update';
|
import { createMySQLDuplicateKeyUpdate } from '../util/on-duplicate-key-update';
|
||||||
const Switches = require('../switches');
|
|
||||||
|
|
||||||
const Media = require('cytube-mediaquery/lib/media');
|
const Media = require('cytube-mediaquery/lib/media');
|
||||||
|
|
||||||
|
@ -28,8 +27,6 @@ class MetadataCacheDB {
|
||||||
}
|
}
|
||||||
|
|
||||||
async put(media) {
|
async put(media) {
|
||||||
if (!Switches.isActive('ytCache')) return;
|
|
||||||
|
|
||||||
media = new Media(media);
|
media = new Media(media);
|
||||||
media.type = mediaquery2cytube(media.type);
|
media.type = mediaquery2cytube(media.type);
|
||||||
return this.db.runTransaction(async tx => {
|
return this.db.runTransaction(async tx => {
|
||||||
|
@ -37,10 +34,11 @@ class MetadataCacheDB {
|
||||||
.insert({
|
.insert({
|
||||||
id: media.id,
|
id: media.id,
|
||||||
type: media.type,
|
type: media.type,
|
||||||
metadata: JSON.stringify(media)
|
metadata: JSON.stringify(media),
|
||||||
|
updated_at: tx.raw('CURRENT_TIMESTAMP')
|
||||||
});
|
});
|
||||||
let update = tx.raw(createMySQLDuplicateKeyUpdate(
|
let update = tx.raw(createMySQLDuplicateKeyUpdate(
|
||||||
['metadata']
|
['metadata', 'updated_at']
|
||||||
));
|
));
|
||||||
|
|
||||||
return tx.raw(insert.toString() + update.toString());
|
return tx.raw(insert.toString() + update.toString());
|
||||||
|
@ -48,8 +46,6 @@ class MetadataCacheDB {
|
||||||
}
|
}
|
||||||
|
|
||||||
async get(id, type) {
|
async get(id, type) {
|
||||||
if (!Switches.isActive('ytCache')) return null;
|
|
||||||
|
|
||||||
return this.db.runTransaction(async tx => {
|
return this.db.runTransaction(async tx => {
|
||||||
let row = await tx.table('media_metadata_cache')
|
let row = await tx.table('media_metadata_cache')
|
||||||
.where({ id, type })
|
.where({ id, type })
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
const switches = {
|
const switches = {
|
||||||
ytCache: true
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isActive(switchName) {
|
export function isActive(switchName) {
|
||||||
|
|
Loading…
Reference in New Issue