Skip to content

Commit

Permalink
chore: remove unsed vars & cleanups (actualbudget#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis authored and eshaffer321 committed Jan 19, 2023
1 parent 1b2ac09 commit f962d35
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 121 deletions.
3 changes: 1 addition & 2 deletions packages/desktop-client/src/components/LoggedInUser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux';
import { useHistory, withRouter } from 'react-router';
import { withRouter } from 'react-router';

import * as actions from 'loot-core/src/client/actions';
import {
Expand Down Expand Up @@ -29,7 +29,6 @@ function LoggedInUser({
let [loading, setLoading] = useState(true);
let [menuOpen, setMenuOpen] = useState(false);
const serverUrl = useServerURL();
const history = useHistory();

useEffect(() => {
getUserData().then(() => setLoading(false));
Expand Down
9 changes: 3 additions & 6 deletions packages/loot-core/src/server/aql/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,27 +560,24 @@ const compileFunction = saveStack('function', (state, func) => {
}
case '$lower': {
validateArgLength(args, 1);
// eslint-disable-next-line no-unused-vars
let [arg1] = valArray(state, args, ['string']);
return typed(`LOWER(${arg1})`, 'string');
}

// integer/float functions
case '$neg': {
validateArgLength(args, 1);
// eslint-disable-next-line no-unused-vars
let [arg1] = valArray(state, args, ['float']);
valArray(state, args, ['float']);
return typed(`(-${val(state, args[0])})`, args[0].type);
}
case '$abs': {
validateArgLength(args, 1);
// eslint-disable-next-line no-unused-vars
let [arg1] = valArray(state, args, ['float']);
valArray(state, args, ['float']);
return typed(`ABS(${val(state, args[0])})`, args[0].type);
}
case '$idiv': {
validateArgLength(args, 2);
let [arg1, arg2] = valArray(state, args, ['integer', 'integer']);
valArray(state, args, ['integer', 'integer']);
return typed(
`(${val(state, args[0])} / ${val(state, args[1])})`,
args[0].type
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Spreadsheet querying deep join works 1`] = `"=from transactions where acct.offbudget = 0 and (description.transfer_acct.offbudget = null or description.transfer_acct.offbudget = 1) select { acct.offbudget, description.transfer_acct.offbudget as foo, amount }"`;

exports[`Spreadsheet querying transactions works 1`] = `"=from transactions select { amount, category }"`;
2 changes: 1 addition & 1 deletion packages/loot-core/src/server/spreadsheet/spreadsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export default class Spreadsheet {
this.events.emit('change', { names: this.computeQueue });

// Cache the updated cells
if (this.saveCache) {
if (typeof this.saveCache === 'function') {
this.saveCache(this.computeQueue);
}
this.markCacheSafe();
Expand Down
70 changes: 34 additions & 36 deletions packages/loot-core/src/server/spreadsheet/spreadsheet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ function wait(n) {
return new Promise(resolve => setTimeout(resolve, n));
}

// TODO: re-enable and fix these tests
// eslint-disable-next-line no-unused-vars
async function insertTransactions(payeeId = null) {
await db.insertAccount({ id: '1', name: 'checking', offbudget: 0 });
await db.insertAccount({ id: '2', name: 'checking', offbudget: 1 });
Expand All @@ -20,7 +18,7 @@ async function insertTransactions(payeeId = null) {
await db.insertTransaction(
generateTransaction({
amount: -3200,
acct: '1',
account: '1',
category: 'cat1',
date: '2017-01-08',
description: payeeId
Expand All @@ -29,7 +27,7 @@ async function insertTransactions(payeeId = null) {
await db.insertTransaction(
generateTransaction({
amount: -2800,
acct: '1',
account: '1',
category: 'cat2',
date: '2017-01-10',
description: payeeId
Expand All @@ -38,7 +36,7 @@ async function insertTransactions(payeeId = null) {
await db.insertTransaction(
generateTransaction({
amount: -9832,
acct: '1',
account: '1',
category: 'cat2',
date: '2017-01-15',
description: payeeId
Expand Down Expand Up @@ -109,40 +107,40 @@ describe('Spreadsheet', () => {
// });
// });

// test('querying transactions works', async () => {
// const spreadsheet = new Spreadsheet(db);
// await insertTransactions();

// spreadsheet.startTransaction();
// spreadsheet.set('g!foo', `=from transactions select { amount, category }`);
// spreadsheet.endTransaction();

// return new Promise(resolve => {
// spreadsheet.onFinish(() => {
// expect(spreadsheet.getValue('g!foo')).toMatchSnapshot();
// resolve();
// });
// });
// });
test('querying transactions works', async () => {
const spreadsheet = new Spreadsheet(db);
await insertTransactions();

// test('querying deep join works', async () => {
// const spreadsheet = new Spreadsheet(db);
// let payeeId1 = await db.insertPayee({ name: '', transfer_acct: '1' });
// let payeeId2 = await db.insertPayee({ name: '', transfer_acct: '2' });
// await insertTransactions(payeeId2);
spreadsheet.startTransaction();
spreadsheet.set('g!foo', `=from transactions select { amount, category }`);
spreadsheet.endTransaction();

// spreadsheet.set(
// 'g!foo',
// '=from transactions where acct.offbudget = 0 and (description.transfer_acct.offbudget = null or description.transfer_acct.offbudget = 1) select { acct.offbudget, description.transfer_acct.offbudget as foo, amount }'
// );
return new Promise(resolve => {
spreadsheet.onFinish(() => {
expect(spreadsheet.getValue('g!foo')).toMatchSnapshot();
resolve();
});
});
});

// return new Promise(resolve => {
// spreadsheet.onFinish(() => {
// expect(spreadsheet.getValue('g!foo')).toMatchSnapshot();
// resolve();
// });
// });
// });
test('querying deep join works', async () => {
const spreadsheet = new Spreadsheet(db);
await db.insertPayee({ name: '', transfer_acct: '1' });
let payeeId2 = await db.insertPayee({ name: '', transfer_acct: '2' });
await insertTransactions(payeeId2);

spreadsheet.set(
'g!foo',
'=from transactions where acct.offbudget = 0 and (description.transfer_acct.offbudget = null or description.transfer_acct.offbudget = 1) select { acct.offbudget, description.transfer_acct.offbudget as foo, amount }'
);

return new Promise(resolve => {
spreadsheet.onFinish(() => {
expect(spreadsheet.getValue('g!foo')).toMatchSnapshot();
resolve();
});
});
});

test('async cells work', done => {
const spreadsheet = new Spreadsheet();
Expand Down
49 changes: 0 additions & 49 deletions packages/loot-design/src/svg/AnimatedLoading.mobile.js

This file was deleted.

27 changes: 0 additions & 27 deletions packages/loot-design/src/svg/AnimatedLoading.web.js

This file was deleted.

0 comments on commit f962d35

Please sign in to comment.