mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
fix: reading JSON string from service_usage_monthly
This was hilariously difficult to debug. This isn't the first time an issue like this occurred; this happens because of a deviation between mysql and sqlite, where a JSON-typed column in mysql will return as a native object in queries, whereas a JSON-typed column in sqlite is a string column and will therefore return as an un-parsed JSON string in queries.
This commit is contained in:
parent
7ba16d1c21
commit
b30de5bf78
@ -60,11 +60,18 @@ module.exports = eggspress('/drivers/usage', {
|
||||
|
||||
for ( const row of rows ) {
|
||||
const app = await get_app({ id: row.app_id });
|
||||
|
||||
|
||||
let extra_parsed;
|
||||
try {
|
||||
extra_parsed = JSON.parse(row.extra);
|
||||
extra_parsed = db.case({
|
||||
mysql: () => row.extra,
|
||||
otherwise: () => JSON.parse(row.extra),
|
||||
})();
|
||||
} catch ( e ) {
|
||||
console.log(
|
||||
'\x1B[31;1m error parsing monthly usage extra',
|
||||
row.extra, e,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user