Skip to content

Commit

Permalink
Merge pull request #2158 from quadratichq/qa
Browse files Browse the repository at this point in the history
QA: Jan 6th
  • Loading branch information
davidkircos authored Jan 10, 2025
2 parents c85c820 + b0e7aff commit 927f1a7
Show file tree
Hide file tree
Showing 40 changed files with 815 additions and 123 deletions.
45 changes: 36 additions & 9 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ edition = "2021"
description = "Infinite data grid with Python, JavaScript, and SQL built-in"
repository = "https://github.com/quadratichq/quadratic"
license-file = "LICENSE"
version = "0.6.0"
version = "0.6.1"

[profile.release]
# Tell `rustc` to optimize for small code size.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.0
0.6.1
10 changes: 6 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quadratic",
"version": "0.6.0",
"version": "0.6.1",
"author": {
"name": "David Kircos",
"email": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion quadratic-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quadratic-api",
"version": "0.6.0",
"version": "0.6.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion quadratic-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quadratic-client",
"version": "0.6.0",
"version": "0.6.1",
"author": {
"name": "David Kircos",
"email": "[email protected]",
Expand Down
8 changes: 8 additions & 0 deletions quadratic-client/src/app/ai/docs/FormulaDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ Returns the counterclockwise angle, in radians, from the X axis to the point \`(
If both arguments are zero, returns zero.
## Financial functions
| **Function** | **Description** |
| ------------ | --------------- |
| \`PMT(rate, nper, pv, [fv], [type])\` | Calculates the payment for a loan based on constant payments and a constant interest rate. Rate is the interest rate per period (e.g., 0.08/12 for 8% annual rate with monthly payments), nper is the total number of payments (e.g., 5*12 for 5 years of monthly payments), pv is the present value (loan amount), fv is the future value (default 0), and type indicates when payments are due (0=end of period, 1=beginning of period, default 0). Returns the negative of the payment amount. |
## Statistics functions
| **Function** | **Description** |
Expand All @@ -371,6 +377,8 @@ If both arguments are zero, returns zero.
| \`COUNTIFS(eval_range1, criteria1, [more_eval_ranges_and_criteria...])\` | Evaluates multiple values on they're respective criteria, and then counts how many sets of values met all their criteria. See [the documentation](https://docs.quadratichq.com/formulas) for more details about how criteria work in formulas. |
| \`MIN([numbers...])\` | Returns the smallest value. Returns +∞ if given no values. |
| \`MAX([numbers...])\` | Returns the largest value. Returns -∞ if given no values. |
| \`STDEV([numbers...])\` | Returns the standard deviation of all values. |
| \`VAR([numbers...])\` | Returns the variance of all values. |
### COUNT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function EmptyGridMessage() {
</div>
<h2 className="text-md font-semibold">Import data</h2>
<p className="text-sm text-muted-foreground">
Bring in your own data via a file (CSV, Excel, Parquet) or a connection (Postgres, MySQL, and more).
Drag and drop a file (CSV, Excel, Parquet) or use a connection (Postgres, MySQL, and more).
</p>
<div className="mt-2 flex w-full flex-col justify-center gap-2">
<UploadFileButton teamUuid={teamUuid} />
Expand Down
2 changes: 1 addition & 1 deletion quadratic-client/src/routes/examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const Component = () => {

const files: FilesListExampleFile[] = examples.map(({ name, description, thumbnail, url }, i) => ({
description,
href: ROUTES.CREATE_FILE_EXAMPLE(activeTeamUuid, url, true),
href: ROUTES.CREATE_FILE_EXAMPLE(activeTeamUuid, url),
name,
thumbnail: thumbnail + '?w=800&h=450&fit=crop&auto=format', // 16/9 aspect ratio
}));
Expand Down
27 changes: 24 additions & 3 deletions quadratic-client/src/routes/files.create.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
import getActiveTeam from '@/dashboard/shared/getActiveTeam';
import { apiClient } from '@/shared/api/apiClient';
import { ROUTES } from '@/shared/constants/routes';
import { ROUTES, SEARCH_PARAMS } from '@/shared/constants/routes';
import { LoaderFunctionArgs, redirect } from 'react-router-dom';

export const loader = async ({ request }: LoaderFunctionArgs) => {
const url = new URL(request.url);
const prompt = url.searchParams.get('prompt');

// Get the active team
const { teams } = await apiClient.teams.list();
const { teamUuid } = await getActiveTeam(teams, undefined);

const redirectUrl = ROUTES.CREATE_FILE(teamUuid, { prompt, private: true });
// Ensure the active team is _writeable_. If it's not, redirect them to the dashboard.
// (They may have write access to another team, but not the 'active' one.)
const team = teams.find(({ team }) => team.uuid === teamUuid);
if (!team?.userMakingRequest.teamPermissions.includes('TEAM_EDIT')) {
return redirect(
`/?${SEARCH_PARAMS.SNACKBAR_MSG.KEY}=${encodeURIComponent('Failed to create file. You can only view this team.')}`
);
}

// Are they trying to duplicate an example file? Do that.
const example = url.searchParams.get('example');
if (example) {
return redirect(ROUTES.CREATE_FILE_EXAMPLE(teamUuid, example));
}

// Otherwise, start a new file by redirecting them to the file creation route
const redirectUrl = ROUTES.CREATE_FILE(teamUuid, {
// Are they creating a new file with a prompt?
prompt: url.searchParams.get('prompt'),
// Creating via this route is _always_ private
private: true,
});
return redirect(redirectUrl);
};
4 changes: 2 additions & 2 deletions quadratic-client/src/shared/components/ShareDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function ShareTeamDialog({ data }: { data: ApiTypes['/v0/teams/:uuid.GET.
)}

{license.status === 'exceeded' && (
<div className="relative rounded border border-red-400 bg-red-100 px-4 py-3 text-red-700" role="alert">
<div className="relative rounded border border-red-400 bg-red-100 px-4 py-3 text-sm text-red-700" role="alert">
<div>
<strong className="font-bold">Over the user limit!</strong>
</div>
Expand All @@ -132,7 +132,7 @@ export function ShareTeamDialog({ data }: { data: ApiTypes['/v0/teams/:uuid.GET.
)}

{license.status === 'revoked' && (
<div className="relative rounded border border-red-400 bg-red-100 px-4 py-3 text-red-700" role="alert">
<div className="relative rounded border border-red-400 bg-red-100 px-4 py-3 text-sm text-red-700" role="alert">
<div>
<strong className="font-bold">License Revoked!</strong>
</div>
Expand Down
4 changes: 2 additions & 2 deletions quadratic-client/src/shared/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export const ROUTES = {

return url.toString();
},
CREATE_FILE_EXAMPLE: (teamUuid: string, publicFileUrlInProduction: string, isPrivate: boolean) =>
`/teams/${teamUuid}/files/create?example=${publicFileUrlInProduction}${isPrivate ? '&private' : ''}`,
CREATE_FILE_EXAMPLE: (teamUuid: string, publicFileUrlInProduction: string) =>
`/teams/${teamUuid}/files/create?example=${publicFileUrlInProduction}&private`,
TEAMS: `/teams`,
TEAMS_CREATE: `/teams/create`,
TEAM: (teamUuid: string) => `/teams/${teamUuid}`,
Expand Down
2 changes: 1 addition & 1 deletion quadratic-connection/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quadratic-connection"
version = "0.6.0"
version = "0.6.1"
edition = "2021"
authors = ["David DiMaria <[email protected]>"]

Expand Down
3 changes: 2 additions & 1 deletion quadratic-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quadratic-core"
version = "0.6.0"
version = "0.6.1"
authors = ["Andrew Farkas <[email protected]>"]
edition = "2021"
description = "Infinite data grid with Python, JavaScript, and SQL built-in"
Expand Down Expand Up @@ -86,6 +86,7 @@ bincode = "1.3.3"
flate2 = "1.0.30"
serde_with = "3.8.1"
dateparser = "0.2.1"
fancy-regex = "0.14.0"

[dev-dependencies]
criterion = { version = "0.4", default-features = false }
Expand Down
44 changes: 44 additions & 0 deletions quadratic-core/src/a1/a1_selection/a1_selection_mutate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,25 @@ impl A1Selection {
selection.translate_in_place(x, y);
selection
}

pub fn adjust_column_row_in_place(
&mut self,
column: Option<i64>,
row: Option<i64>,
delta: i64,
) {
self.cursor.adjust_column_row_in_place(column, row, delta);
self.ranges.iter_mut().for_each(|range| {
range.adjust_column_row_in_place(column, row, delta);
});
}
}

#[cfg(test)]
#[serial_test::parallel]
mod tests {
use crate::{grid::SheetId, SheetNameIdMap};

use super::*;

#[test]
Expand Down Expand Up @@ -426,4 +440,34 @@ mod tests {
assert_eq!(translated, A1Selection::test_a1("A1"));
assert_eq!(selection, A1Selection::test_a1("A1"));
}

#[test]
fn test_adjust_column_row() {
let sheet_id = SheetId::test();
let sheet_map = SheetNameIdMap::new();

let mut selection = A1Selection::test_a1("B3");
selection.adjust_column_row_in_place(Some(2), None, 1);
assert_eq!(selection.to_string(Some(sheet_id), &sheet_map), "C3");

let mut selection = A1Selection::test_a1("B3");
selection.adjust_column_row_in_place(None, Some(2), 1);
assert_eq!(selection.to_string(Some(sheet_id), &sheet_map), "B4");

let mut selection = A1Selection::test_a1("B3");
selection.adjust_column_row_in_place(Some(3), None, 1);
assert_eq!(selection.to_string(Some(sheet_id), &sheet_map), "B3");

let mut selection = A1Selection::test_a1("B3");
selection.adjust_column_row_in_place(None, Some(4), 1);
assert_eq!(selection.to_string(Some(sheet_id), &sheet_map), "B3");

let mut selection = A1Selection::test_a1("B3");
selection.adjust_column_row_in_place(Some(1), None, -1);
assert_eq!(selection.to_string(Some(sheet_id), &sheet_map), "A3");

let mut selection = A1Selection::test_a1("B3");
selection.adjust_column_row_in_place(None, Some(1), -1);
assert_eq!(selection.to_string(Some(sheet_id), &sheet_map), "B2");
}
}
Loading

0 comments on commit 927f1a7

Please sign in to comment.