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

Add series tool in query builder #4952

Open
wants to merge 36 commits into
base: production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c0d7cba
Display cat number range for disctinct queries
CarolineDenis May 13, 2024
8141c5d
Comment out
CarolineDenis May 14, 2024
ebb48b7
test series on front end
CarolineDenis May 14, 2024
ee0813a
Test grouping results by following ids
CarolineDenis May 15, 2024
42ed6c5
Test condition
CarolineDenis May 15, 2024
648b222
Try reduce
CarolineDenis May 15, 2024
36c6c6d
comment
CarolineDenis May 24, 2024
26cedcc
Reset
CarolineDenis May 24, 2024
36481c3
Add series to frontend
CarolineDenis May 24, 2024
53aafe7
Merge remote-tracking branch 'origin/production' into issue-2000
CarolineDenis May 24, 2024
5ee0e80
Only display series for CO with Cat Num in fields
CarolineDenis May 24, 2024
186a0f6
Fix boolean
CarolineDenis May 24, 2024
70c84d7
Remove import
CarolineDenis May 24, 2024
eba3b4c
Start to add series to backend
CarolineDenis May 24, 2024
e5a2d50
Group by before limit
CarolineDenis May 24, 2024
d6f3ff9
Add comment
CarolineDenis May 24, 2024
fed542f
Add series logic
CarolineDenis May 24, 2024
a1e3745
Start work on concat cat number
CarolineDenis May 24, 2024
33f43bf
Notes to concat cat number
CarolineDenis May 28, 2024
862830b
Merge remote-tracking branch 'origin/production' into issue-2000
CarolineDenis Jul 19, 2024
d653b76
Group cat number together test
CarolineDenis Jul 19, 2024
31eae2f
Merge remote-tracking branch 'origin/production' into issue-2000
CarolineDenis Dec 2, 2024
013e23c
Merge remote-tracking branch 'origin/production' into issue-2000
CarolineDenis Dec 6, 2024
f9e02b6
Merge remote-tracking branch 'origin/production' into issue-2000
CarolineDenis Jan 28, 2025
7fa96c9
Merge branch 'production' into issue-2000
acwhite211 Jan 28, 2025
f4cc35d
implement back-end changes to meet Series QB features
acwhite211 Jan 30, 2025
7a3707e
Only allow series or distinct
CarolineDenis Jan 30, 2025
b807207
remove duplicate code
acwhite211 Jan 31, 2025
55dbc0f
better series_post_query function
acwhite211 Jan 31, 2025
95d4d60
cleanup
acwhite211 Jan 31, 2025
de9d48d
Verify field.key exist
CarolineDenis Feb 3, 2025
b40a50b
enforce limit on series_post_query
acwhite211 Feb 3, 2025
af0fc33
set max rows for series_post_query to return
acwhite211 Feb 3, 2025
7177b63
fix series query logic to handle alphanumeric cat nums
acwhite211 Feb 27, 2025
ed0fd1e
allow for series qb records to be sorted by ranged cat nums
acwhite211 Feb 27, 2025
c9b471e
Merge branch 'production' into issue-2000
acwhite211 Feb 27, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ describe('serializeResource', () => {
remarks: null,
searchSynonymy: null,
selectDistinct: null,
selectSeries: null,
smushed: null,
specifyUser: null,
sqlStr: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5291,6 +5291,7 @@ export type SpQuery = {
readonly remarks: string | null;
readonly searchSynonymy: boolean | null;
readonly selectDistinct: boolean | null;
readonly selectSeries: boolean | null;
readonly smushed: boolean | null;
readonly sqlStr: string | null;
readonly timestampCreated: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ overrideAjax(
resource_uri: undefined,
searchsynonymy: null,
selectdistinct: false,
selectseries: false,
smushed: null,
specifyuser: '/api/specify/specifyuser/2/',
sqlstr: null,
Expand Down
17 changes: 17 additions & 0 deletions specifyweb/frontend/js_src/lib/components/QueryBuilder/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@ export function QueryToolbar({
showHiddenFields,
tableName,
isDistinct,
isSeries,
showSeries,
onToggleHidden: handleToggleHidden,
onToggleDistinct: handleToggleDistinct,
onToggleSeries: handleToggleSeries,
onRunCountOnly: handleRunCountOnly,
onSubmitClick: handleSubmitClick,
}: {
readonly showHiddenFields: boolean;
readonly tableName: keyof Tables;
readonly isDistinct: boolean;
readonly isSeries: boolean;
readonly showSeries: boolean;
readonly onToggleHidden: (value: boolean) => void;
readonly onToggleDistinct: () => void;
readonly onToggleSeries: () => void;
readonly onRunCountOnly: () => void;
readonly onSubmitClick: () => void;
}): JSX.Element {
Expand All @@ -38,6 +44,16 @@ export function QueryToolbar({
<span className="-ml-2 flex-1" />
{hasPermission('/querybuilder/query', 'execute') && (
<>
{showSeries && (
<Label.Inline>
<Input.Checkbox
checked={isSeries}
isReadOnly={isDistinct}
onChange={handleToggleSeries}
/>
{queryText.series()}
</Label.Inline>
)}
{/*
* Query Distinct for trees is disabled because of
* https://github.com/specify/specify7/pull/1019#issuecomment-973525594
Expand All @@ -46,6 +62,7 @@ export function QueryToolbar({
<Label.Inline>
<Input.Checkbox
checked={isDistinct}
isReadOnly={isSeries}
onChange={handleToggleDistinct}
/>
{queryText.distinct()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function Wrapped({
readonly onChange?: (props: {
readonly fields: RA<SerializedResource<SpQueryField>>;
readonly isDistinct: boolean | null;
readonly isSeries: boolean | null;
}) => void;
}): JSX.Element {
const [query, setQuery] = useResource(queryResource);
Expand Down Expand Up @@ -157,8 +158,9 @@ function Wrapped({
handleChange?.({
fields: unParseQueryFields(state.baseTableName, state.fields),
isDistinct: query.selectDistinct,
isSeries: query.selectSeries,
});
}, [state, query.selectDistinct]);
}, [state, query.selectDistinct, query.selectSeries]);

/**
* If tried to save a query, enforce the field length limit for the
Expand Down Expand Up @@ -296,6 +298,10 @@ function Wrapped({
undefined
);

const showSeries =
table.name === 'CollectionObject' &&
state.fields.some((field) => field.mappingPath[0] === 'catalogNumber');

return treeRanksLoaded ? (
<ReadOnlyContext.Provider value={isReadOnly}>
<IsQueryBasicContext.Provider value={isBasic}>
Expand Down Expand Up @@ -556,6 +562,8 @@ function Wrapped({
/>
<QueryToolbar
isDistinct={query.selectDistinct ?? false}
isSeries={query.selectSeries ?? false}
showSeries={showSeries}
showHiddenFields={showHiddenFields}
tableName={table.name}
onRunCountOnly={(): void => runQuery('count')}
Expand All @@ -570,6 +578,12 @@ function Wrapped({
selectDistinct: !(query.selectDistinct ?? false),
})
}
onToggleSeries={(): void =>
setQuery({
...query,
selectSeries: !(query.selectSeries ?? false),
})
}
onToggleHidden={setShowHiddenFields}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ exports[`queryFromTree 1`] = `
"name": "Collection Object using \\"Los Angeles County\\"",
"ordinal": 32767,
"selectdistinct": false,
"selectseries": false,
"specifyuser": "/api/specify/specifyuser/2/",
},
{
Expand Down Expand Up @@ -160,6 +161,7 @@ exports[`queryFromTree 1`] = `
"name": "Collection Object using \\"Cabinet 1\\"",
"ordinal": 32767,
"selectdistinct": false,
"selectseries": false,
"specifyuser": "/api/specify/specifyuser/2/",
},
{
Expand Down Expand Up @@ -234,6 +236,7 @@ exports[`queryFromTree 1`] = `
"name": "Collection Object using \\"Carpiodes velifer\\"",
"ordinal": 32767,
"selectdistinct": false,
"selectseries": false,
"specifyuser": "/api/specify/specifyuser/2/",
},
{
Expand Down Expand Up @@ -308,6 +311,7 @@ exports[`queryFromTree 1`] = `
"name": "Collection Object using \\"Paleocene\\"",
"ordinal": 32767,
"selectdistinct": false,
"selectseries": false,
"specifyuser": "/api/specify/specifyuser/2/",
},
{
Expand Down Expand Up @@ -382,6 +386,7 @@ exports[`queryFromTree 1`] = `
"name": "Collection Object using \\"Cretaceous\\"",
"ordinal": 32767,
"selectdistinct": false,
"selectseries": false,
"specifyuser": "/api/specify/specifyuser/2/",
},
{
Expand Down Expand Up @@ -456,6 +461,7 @@ exports[`queryFromTree 1`] = `
"name": "Collection Object using \\"Plate\\"",
"ordinal": 32767,
"selectdistinct": false,
"selectseries": false,
"specifyuser": "/api/specify/specifyuser/2/",
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function createQuery(
query.set('contextName', table.name);
query.set('contextTableId', table.tableId);
query.set('selectDistinct', false);
query.set('selectSeries', false);
query.set('countOnly', false);
query.set('formatAuditRecIds', false);
query.set('specifyUser', userInformation.resource_uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function makeComboBoxQuery({
query.set('contextName', table.name);
query.set('contextTableId', table.tableId);
query.set('selectDistinct', false);
query.set('selectSeries', false);
query.set('countOnly', false);
query.set('specifyUser', userInformation.resource_uri);
query.set('isFavorite', false);
Expand Down
3 changes: 3 additions & 0 deletions specifyweb/frontend/js_src/lib/localization/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ export const queryText = createDictionary({
'uk-ua': 'Виразний',
'de-ch': 'Unterscheidbar',
},
series: {
'en-us': 'Series',
},
createCsv: {
'en-us': 'Create CSV',
'ru-ru': 'Создать CSV-файл',
Expand Down
Loading
Loading