Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 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
baf9edf
fix query results return limit
acwhite211 Mar 10, 2025
d8048de
edit series count function
acwhite211 Mar 11, 2025
a4853e6
handle null cat num in series
acwhite211 Mar 21, 2025
bacbe8d
Merge branch 'production' into issue-2000
acwhite211 Mar 21, 2025
1272641
fix merge conflict errors
acwhite211 Mar 21, 2025
1f669f9
handle int and none cat num id
acwhite211 Mar 24, 2025
81e92a7
execute query call fix
acwhite211 Mar 24, 2025
728351e
handle series decimal cat nums
acwhite211 Mar 24, 2025
5610d16
better reverse series with count and offset fix
acwhite211 Mar 25, 2025
ec557e9
Set series to false when remove cat num filter
CarolineDenis Mar 25, 2025
e9486a7
Merge branch 'production' into issue-2000
acwhite211 Mar 25, 2025
cb80b14
SERIES_MAX_ROWS increase
acwhite211 Mar 25, 2025
0fb9ad6
remove series limit
acwhite211 Mar 25, 2025
deaeeca
reverse ordering fix
acwhite211 Mar 25, 2025
831d34b
limit fix
acwhite211 Mar 25, 2025
fbe3c65
tests + model field
CarolineDenis Mar 25, 2025
8c136ed
offset fix
acwhite211 Mar 25, 2025
e658030
selectseries django migration
acwhite211 Mar 25, 2025
9f7125f
fix predicates on catanum field in series queries
acwhite211 Apr 11, 2025
c56933f
Merge branch 'production' into issue-2000
acwhite211 Apr 11, 2025
7aceeba
Lint code with ESLint and Prettier
acwhite211 Apr 11, 2025
285de33
add parsing of more catnum formats for series grouping logic
acwhite211 Apr 15, 2025
d54a6c8
reorder format parsing
acwhite211 Apr 15, 2025
595bea6
match correction
acwhite211 Apr 15, 2025
c00f2a1
co formatted query error fix
acwhite211 Apr 17, 2025
34ec30c
Merge branch 'production' into issue-2000
acwhite211 Apr 17, 2025
762e9e2
cog_inheritance_post_query_processing fix
acwhite211 Apr 18, 2025
4c47595
other join_path error fix
acwhite211 Apr 18, 2025
d594fbe
Merge branch 'production' into issue-2000
acwhite211 Apr 18, 2025
0f78de3
null get field fix
acwhite211 Apr 18, 2025
38621d3
Merge branch 'production' into issue-2000
acwhite211 Apr 28, 2025
cf65548
Update and rename 0027_selectseries.py to 0028_selectseries.py
acwhite211 Apr 29, 2025
d2d0794
Hide serie checkbox if cat num field hidden
CarolineDenis May 6, 2025
fdce581
Update show series when fields update
CarolineDenis May 6, 2025
f35c3ee
formatted_field fix
acwhite211 May 6, 2025
e8b8dd4
fix sorted_pairs in series qb
acwhite211 May 8, 2025
23b9f0f
Merge remote-tracking branch 'origin/production' into issue-2000
CarolineDenis May 8, 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
1 change: 1 addition & 0 deletions config/specify_datamodel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4169,6 +4169,7 @@
<field column="Remarks" name="remarks" type="text" length="4096" updatable="true" required="false" unique="false" indexed="false" partialDate="false"/>
<field column="SearchSynonymy" name="searchSynonymy" type="java.lang.Boolean" updatable="true" required="false" unique="false" indexed="false" partialDate="false"/>
<field column="SelectDistinct" name="selectDistinct" type="java.lang.Boolean" updatable="true" required="false" unique="false" indexed="false" partialDate="false"/>
<field column="SelectSeries" name="SelectSeries" type="java.lang.Boolean" updatable="true" required="false" unique="false" indexed="false" partialDate="false"/>
<field column="Smushed" name="smushed" type="java.lang.Boolean" updatable="true" required="false" unique="false" indexed="false" partialDate="false"/>
<field column="SqlStr" name="sqlStr" type="text" length="4096" updatable="true" required="false" unique="false" indexed="false" partialDate="false"/>
<field column="TimestampCreated" name="timestampCreated" type="java.sql.Timestamp" updatable="false" required="true" unique="false" indexed="false" partialDate="false"/>
Expand Down
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 @@ -5299,6 +5299,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 @@ -96,6 +96,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 @@ -160,8 +161,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 @@ -299,6 +301,23 @@ function Wrapped({
undefined
);

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

React.useEffect(() => {
if (!showSeries)
setQuery({
...query,
selectSeries: false,
});
}, [showSeries]);

return treeRanksLoaded ? (
<ReadOnlyContext.Provider value={isReadOnly}>
<IsQueryBasicContext.Provider value={isBasic}>
Expand Down Expand Up @@ -559,7 +578,9 @@ function Wrapped({
/>
<QueryToolbar
isDistinct={query.selectDistinct ?? false}
isSeries={query.selectSeries ?? false}
showHiddenFields={showHiddenFields}
showSeries={showSeries}
tableName={table.name}
onRunCountOnly={(): void => runQuery('count')}
onSubmitClick={(): void =>
Expand All @@ -574,6 +595,12 @@ function Wrapped({
})
}
onToggleHidden={setShowHiddenFields}
onToggleSeries={(): void =>
setQuery({
...query,
selectSeries: !(query.selectSeries ?? false),
})
}
/>
</div>
{hasPermission('/querybuilder/query', 'execute') && (
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
Original file line number Diff line number Diff line change
Expand Up @@ -31078,6 +31078,14 @@
"required": false,
"type": "java.lang.Boolean"
},
{
"name": "selectSeries",
"column": "SelectSeries",
"indexed": false,
"unique": false,
"required": false,
"type": "java.lang.Boolean"
},
{
"name": "smushed",
"column": "Smushed",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38532,6 +38532,17 @@
"name": "Select Distinct",
"desc": "Select Distinct"
},
"selectseries": {
"format": null,
"ishidden": false,
"isuiformatter": false,
"picklistname": null,
"type": null,
"isrequired": false,
"weblinkname": null,
"name": "Select Series",
"desc": "Select Series"
},
"smushed": {
"format": null,
"ishidden": false,
Expand Down
1 change: 1 addition & 0 deletions specifyweb/specify/datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6595,6 +6595,7 @@ def is_tree_table(table: Table):
Field(name='remarks', column='Remarks', indexed=False, unique=False, required=False, type='text', length=4096),
Field(name='searchSynonymy', column='SearchSynonymy', indexed=False, unique=False, required=False, type='java.lang.Boolean'),
Field(name='selectDistinct', column='SelectDistinct', indexed=False, unique=False, required=False, type='java.lang.Boolean'),
Field(name='selectSeries', column='SelectSeries', indexed=False, unique=False, required=False, type='java.lang.Boolean'),
Field(name='smushed', column='Smushed', indexed=False, unique=False, required=False, type='java.lang.Boolean'),
Field(name='sqlStr', column='SqlStr', indexed=False, unique=False, required=False, type='text', length=4096),
Field(name='timestampCreated', column='TimestampCreated', indexed=False, unique=False, required=True, type='java.sql.Timestamp'),
Expand Down
18 changes: 18 additions & 0 deletions specifyweb/specify/migrations/0028_selectseries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.15 on 2025-03-25 17:03

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('specify', '0027_CO_children'),
]

operations = [
migrations.AddField(
model_name='spquery',
name='selectseries',
field=models.BooleanField(blank=True, db_column='SelectSeries', null=True),
),
]
1 change: 1 addition & 0 deletions specifyweb/specify/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6261,6 +6261,7 @@ class Spquery(models.Model):
remarks = models.TextField(blank=True, null=True, unique=False, db_column='Remarks', db_index=False)
searchsynonymy = models.BooleanField(blank=True, null=True, unique=False, db_column='SearchSynonymy', db_index=False)
selectdistinct = models.BooleanField(blank=True, null=True, unique=False, db_column='SelectDistinct', db_index=False)
selectseries = models.BooleanField(blank=True, null=True, unique=False, db_column='SelectSeries', db_index=False)
smushed = models.BooleanField(blank=True, null=True, unique=False, db_column='Smushed', db_index=False)
sqlstr = models.TextField(blank=True, null=True, unique=False, db_column='SqlStr', db_index=False)
timestampcreated = models.DateTimeField(blank=False, null=False, unique=False, db_column='TimestampCreated', db_index=False, default=timezone.now)
Expand Down
1 change: 1 addition & 0 deletions specifyweb/specify/temp_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5011,6 +5011,7 @@ class Spquery(models.Model):
remarks = models.TextField(db_column='Remarks', blank=True, null=True) # Field name made lowercase.
searchsynonymy = models.BooleanField(db_column='SearchSynonymy', blank=True, null=True) # Field name made lowercase.
selectdistinct = models.BooleanField(db_column='SelectDistinct', blank=True, null=True) # Field name made lowercase.
selectseries = models.BooleanField(db_column='SelectSeries', blank=True, null=True)
sqlstr = models.TextField(db_column='SqlStr', blank=True, null=True) # Field name made lowercase.
modifiedbyagentid = models.ForeignKey(Agent, models.DO_NOTHING, db_column='ModifiedByAgentID', blank=True, null=True) # Field name made lowercase.
specifyuserid = models.ForeignKey(Specifyuser, models.DO_NOTHING, db_column='SpecifyUserID') # Field name made lowercase.
Expand Down
4 changes: 2 additions & 2 deletions specifyweb/specify/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def log_sqlalchemy_query(query):
from sqlalchemy.dialects import mysql
compiled_query = query.statement.compile(dialect=mysql.dialect(), compile_kwargs={"literal_binds": True})
raw_sql = str(compiled_query).replace('\n', ' ') + ';'
logger.debug('============== SQL Query ==============')
logger.debug('='.join(['' for _ in range(80)]))
logger.debug(raw_sql)
logger.debug('=======================================')
logger.debug('='.join(['' for _ in range(80)]))
# Run in the storred_queries.execute file, in the execute function, right before the return statement, line 546
# from specifyweb.specify.utils import log_sqlalchemy_query; log_sqlalchemy_query(query)

Expand Down
1 change: 1 addition & 0 deletions specifyweb/stored_queries/batch_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,7 @@ def run_batch_edit_query(props: BatchEditProps):
user=props["user"],
tableid=tableid,
distinct=True,
series=False,
count_only=False,
field_specs=query_with_hidden,
limit=limit,
Expand Down
Loading