Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove unsed vars & cleanups #437

Merged
merged 1 commit into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throws an exception if the vars are invalid, so we can't remove it.

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') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making the tests pass.

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 () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only uncommenting these tests. No changes in them.

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.