Skip to content

Commit

Permalink
Issue 237/email report (#244)
Browse files Browse the repository at this point in the history
* Added weekly report
* refactor for arrow functions and preferring named imports
  • Loading branch information
rphovley authored Oct 10, 2024
1 parent 5dc6f3c commit 44c938b
Show file tree
Hide file tree
Showing 102 changed files with 1,470 additions and 349 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,16 @@ module.exports = {
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-explicit-any": "error",
"codeclimbers/use-code-climbers-button": "error",
"prefer-arrow-callback": "warn",
"func-style": ["warn", "expression", { "allowArrowFunctions": true }],
"import/no-default-export": "error",
},
overrides: [
{
files: ["packages/server/commands/**/*.ts"],
rules: {
"import/no-default-export": "off"
}
}
]
};
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ bin/daemon

# firebase cache
.firebase/hosting.*

# npm pack and tarball files
*.tgz

# mock install
codeclimbers_install_*
1 change: 1 addition & 0 deletions bin/migrations/20240620003646_add_pulses.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const SQL = `--sql
origin_id varchar(255),
created_at timestamp(3),
description text
);
`
exports.up = function (knex) {
Expand Down
36 changes: 36 additions & 0 deletions bin/migrations/20241003221416_add_user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const SQL = `--sql
CREATE TABLE accounts_user (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
email varchar(255) UNIQUE,
first_name varchar(255),
last_name varchar(255),
avatar_url varchar(255),
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
`

const SQL_SETTINGS = `--sql
CREATE TABLE IF NOT EXISTS accounts_user_settings (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
user_id INTEGER NOT NULL,
weekly_report_type VARCHAR(255) NOT NULL DEFAULT '',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES accounts_user (id) ON DELETE CASCADE
);
`

exports.up = async function (knex) {
await knex.raw(SQL)
await knex.raw(SQL_SETTINGS)
return
}

exports.down = function (knex) {
return
// return knex.raw(`--sql
// DROP TABLE accounts_user;
// `)
}
26 changes: 26 additions & 0 deletions bin/migrations/20241004000814_create_user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
exports.up = function(knex) {
return knex.transaction(async (trx) => {
// Insert into accounts_user
await trx('accounts_user').insert({});
const [row] = await trx.raw('SELECT last_insert_rowid() as id');
const userId = row.id;
// Insert into accounts_user_settings
await trx('accounts_user_settings').insert({
user_id: userId
});
});
};

exports.down = function(knex) {
// return knex.transaction(async (trx) => {
// // Remove the last inserted user_settings
// await trx('accounts_user_settings')
// .where('user_id', knex.raw('(SELECT MAX(id) FROM accounts_user)'))
// .del();

// // Remove the last inserted user
// await trx('accounts_user')
// .where('id', knex.raw('(SELECT MAX(id) FROM accounts_user)'))
// .del();
// });
};
5 changes: 4 additions & 1 deletion docs/Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ A React Single Page Application that uses react-router, material-ui, tanstack to
- Any api calls should be included in the `api` directory and make use of tanstack
- All components should reside in the `components` directory.
- All pages should go in the `components` directory and have their own component.
- Functions and variables should be camelCase. Classes should be PascalCase.
- Use named exports when exporting components, functions, variables, etc (no default exports)
- All layout components should go in the `layouts` directory.
- `services` generally are react queries that fetch data from the backend.
- Primarily use kysely for building sql queries. When the query is complex, it may be best to use raw sql.
- Styling: make use of the `sx` attribute for any material-ui customizations.
- Styling: make use of the appropriate material-ui components for layouts like `Grid` or `Stack` when possible,
but `Box` is a great fallback
Expand Down Expand Up @@ -106,6 +107,8 @@ A way for the user to interact with the application easily using oclif
you want changes to be reflected in the CLI from the server, you will need to build it with `npm run build:server` and
then restart the CLI.

A great way to test the CLI is to install it on a machine and then run `npm run mock:install {version} --run` to install an older version of the CLI and test from there.

### Conventions

- TBD
Expand Down
Loading

0 comments on commit 44c938b

Please sign in to comment.