Skip to content

Commit

Permalink
Fix: Add cron job and update transaction mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
shivarm committed Oct 8, 2024
1 parent db62dd2 commit 3069d3a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 27 deletions.
28 changes: 2 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [main]

jobs:
build-backend:
build-expensify:
runs-on: ubuntu-latest

strategy:
Expand All @@ -27,29 +27,5 @@ jobs:
- name: Run CI
run: npm run ci

build-client:
runs-on: ubuntu-latest
needs: build-backend

strategy:
matrix:
node-version: [22.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: install dependencies
run: npm install
working-directory: ./client

- name: Test
run: npm run test
working-directory: ./client

- name: Build
- name: Build Expensify
run: npm run build --if-present
working-directory: ./client
18 changes: 18 additions & 0 deletions backend/cron.job.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import cron from 'cron';
import https from 'https';

const URL = 'https://expensify-f43l.onrender.com';

export const job = new cron.CronJob('*/10 * * * * *', function () {
https
.get(URL, (res) => {
if (res.statusCode === 200) {
console.log('Get request sent successfully');
} else {
console.log('Get request failed');
}
})
.on('error', (e) => {
console.error('Error while sending req', e);
});
});
4 changes: 4 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ import { passportConfig } from './passport/passport.config.js';
import mergeResolvers from './resolvers/index.js';
import mergeTypeDefs from './typeDefs/index.js';

import { job } from './cron.job.js';

dotenv.config();
passportConfig();

job.start();

const __dirname = path.resolve();
const app = express();

Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/Transaction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const TransactionPage = () => {
});

const [updateTransaction] = useMutation(UPDATE_TRANSACTION, {
refetchQueries: ['GetTransactions', 'GetCategoryStatistics'],
refetchQueries: [{ query: 'GetCategoryStatistics' }],
onCompleted: () => {
navigate('/');
},
Expand Down
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"client": "^0.0.1",
"connect-mongodb-session": "^5.0.0",
"cors": "^2.8.5",
"cron": "^3.1.7",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"express-session": "^1.18.0",
Expand Down

0 comments on commit 3069d3a

Please sign in to comment.