Updated countsonly option of gam <UserTypeEntity> print|show notes to additionally display the total number of notes.

This commit is contained in:
Ross Scroggs
2024-04-04 17:57:55 -07:00
parent 23b0b0f203
commit a0dc04e7b0
6 changed files with 31 additions and 20 deletions

View File

@@ -10,10 +10,14 @@ Add the `-s` option to the end of the above commands to suppress creating the `g
See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation
### 6.72.09
Updated `countsonly` option of `gam <UserTypeEntity> print|show notes` to additionally display the total number of notes.
### 6.72.08 ### 6.72.08
Added option `countsonly` to `gam <UserTypeEntity> print|show notes` that displays Added option `countsonly` to `gam <UserTypeEntity> print|show notes` that displays
the number of notes a user owns and the number of notes of user can edit. the number of notes a user owns and the number of notes a user can edit.
### 6.72.07 ### 6.72.07

View File

@@ -334,7 +334,7 @@ writes the credentials into the file oauth2.txt.
admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt
admin@server:/Users/admin/bin/gamadv-xtd3$ ./gam version admin@server:/Users/admin/bin/gamadv-xtd3$ ./gam version
WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found
GAMADV-XTD3 6.72.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.72.09 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.2 64-bit final Python 3.12.2 64-bit final
MacOS Sonoma 14.2.1 x86_64 MacOS Sonoma 14.2.1 x86_64
@@ -1006,7 +1006,7 @@ writes the credentials into the file oauth2.txt.
C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt
C:\GAMADV-XTD3>gam version C:\GAMADV-XTD3>gam version
WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found
GAMADV-XTD3 6.72.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.72.09 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.2 64-bit final Python 3.12.2 64-bit final
Windows-10-10.0.17134 AMD64 Windows-10-10.0.17134 AMD64

View File

@@ -139,8 +139,8 @@ By default, GAM displays all non-trashed notes:
* `filter trashed` - Display notes in the trash * `filter trashed` - Display notes in the trash
* `role owner|writer` - Display notes where the user has the specified role * `role owner|writer` - Display notes where the user has the specified role
When option `countsonly` is specified, the number of notes a user owns and the number of notes of user can edit When option `countsonly` is specified, the number of notes a user owns, the number of notes of user can edit
if displayed. and the total number of notes is displayed.
By default, Gam displays the information as an indented list of keys and values; the note text is displayed as individual lines. By default, Gam displays the information as an indented list of keys and values; the note text is displayed as individual lines.
* `compact` - Display the note text with escaped carriage returns as \r and newlines as \n * `compact` - Display the note text with escaped carriage returns as \r and newlines as \n
@@ -158,8 +158,8 @@ By default, GAM displays all non-trashed notes:
* `filter trashed` - Display notes in the trash * `filter trashed` - Display notes in the trash
* `role owner|writer` - Display notes where the user has the specified role * `role owner|writer` - Display notes where the user has the specified role
When option `countsonly` is specified, the number of notes a user owns and the number of notes of user can edit When option `countsonly` is specified, the number of notes a user owns, the number of notes of user can edit
if displayed. and the total number of notes is displayed.
By default, when writing CSV files, Gam uses a quote character of double quote `"`. The quote character is used to enclose columns that contain By default, when writing CSV files, Gam uses a quote character of double quote `"`. The quote character is used to enclose columns that contain
the quote character itself, the column delimiter (comma by default) and new-line characters. Any quote characters within the column are doubled. the quote character itself, the column delimiter (comma by default) and new-line characters. Any quote characters within the column are doubled.

View File

@@ -3,7 +3,7 @@
Print the current version of Gam with details Print the current version of Gam with details
``` ```
gam version gam version
GAMADV-XTD3 6.72.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.72.09 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.2 64-bit final Python 3.12.2 64-bit final
MacOS Sonoma 14.2.1 x86_64 MacOS Sonoma 14.2.1 x86_64
@@ -15,7 +15,7 @@ Time: 2023-06-02T21:10:00-07:00
Print the current version of Gam with details and time offset information Print the current version of Gam with details and time offset information
``` ```
gam version timeoffset gam version timeoffset
GAMADV-XTD3 6.72.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.72.09 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.2 64-bit final Python 3.12.2 64-bit final
MacOS Sonoma 14.2.1 x86_64 MacOS Sonoma 14.2.1 x86_64
@@ -27,7 +27,7 @@ Your system time differs from www.googleapis.com by less than 1 second
Print the current version of Gam with extended details and SSL information Print the current version of Gam with extended details and SSL information
``` ```
gam version extended gam version extended
GAMADV-XTD3 6.72.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.72.09 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.2 64-bit final Python 3.12.2 64-bit final
MacOS Sonoma 14.2.1 x86_64 MacOS Sonoma 14.2.1 x86_64
@@ -64,7 +64,7 @@ MacOS High Sierra 10.13.6 x86_64
Path: /Users/Admin/bin/gamadv-xtd3 Path: /Users/Admin/bin/gamadv-xtd3
Version Check: Version Check:
Current: 5.35.08 Current: 5.35.08
Latest: 6.72.08 Latest: 6.72.09
echo $? echo $?
1 1
``` ```
@@ -72,7 +72,7 @@ echo $?
Print the current version number without details Print the current version number without details
``` ```
gam version simple gam version simple
6.72.08 6.72.09
``` ```
In Linux/MacOS you can do: In Linux/MacOS you can do:
``` ```
@@ -82,7 +82,7 @@ echo $VER
Print the current version of Gam and address of this Wiki Print the current version of Gam and address of this Wiki
``` ```
gam help gam help
GAM 6.72.08 - https://github.com/taers232c/GAMADV-XTD3 GAM 6.72.09 - https://github.com/taers232c/GAMADV-XTD3
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.2 64-bit final Python 3.12.2 64-bit final
MacOS Sonoma 14.2.1 x86_64 MacOS Sonoma 14.2.1 x86_64

View File

@@ -2,10 +2,14 @@
Merged GAM-Team version Merged GAM-Team version
6.72.09
Updated `countsonly` option of `gam <UserTypeEntity> print|show notes` to additionally display the total number of notes.
6.72.08 6.72.08
Added option `countsonly` to `gam <UserTypeEntity> print|show notes` that displays Added option `countsonly` to `gam <UserTypeEntity> print|show notes` that displays
the number of notes a user owns and the number of notes of user can edit. the number of notes a user owns and the number of notes a user can edit.
6.72.07 6.72.07

View File

@@ -71349,7 +71349,7 @@ def printShowNotes(users):
csvPF.RemoveJSONTitles(['owner', 'ownedByMe']) csvPF.RemoveJSONTitles(['owner', 'ownedByMe'])
if countsOnly and csvPF: if countsOnly and csvPF:
if not FJQC.formatJSON: if not FJQC.formatJSON:
csvPF.SetTitles(['User', 'noteOwner', 'noteWriter']) csvPF.SetTitles(['User', 'noteOwner', 'noteWriter', 'totalNotes'])
else: else:
csvPF.SetJSONTitles(['User', 'JSON']) csvPF.SetJSONTitles(['User', 'JSON'])
fields = getItemFieldsFromFieldsList('notes', fieldsList, returnItemIfNoneList=False) fields = getItemFieldsFromFieldsList('notes', fieldsList, returnItemIfNoneList=False)
@@ -71370,27 +71370,30 @@ def printShowNotes(users):
throwReasons=GAPI.KEEP_THROW_REASONS, throwReasons=GAPI.KEEP_THROW_REASONS,
filter=noteFilter, fields=fields) filter=noteFilter, fields=fields)
if countsOnly: if countsOnly:
noteCounts = {'User': user, 'noteOwner': 0, 'noteWriter': 0} noteCounts = {'User': user, 'noteOwner': 0, 'noteWriter': 0, 'totalNotes': 0}
for note in notes: for note in notes:
noteCounts['totalNotes'] += 1
for permission in note['permissions']: for permission in note['permissions']:
if permission.get('user', {}).get('email', '').lower() == user: if permission.get('user', {}).get('email', '').lower() == user:
noteCounts[NOTES_COUNTS_MAP[permission['role']]] += 1 noteCounts[NOTES_COUNTS_MAP[permission['role']]] += 1
break break
if not csvPF: if not csvPF:
if not FJQC.formatJSON: if not FJQC.formatJSON:
printEntityKVList([Ent.USER, user], ['noteOwner', noteCounts['noteOwner'], 'noteWriter', noteCounts['noteWriter']], i, count) printEntityKVList([Ent.USER, user], ['noteOwner', noteCounts['noteOwner'],
'noteWriter', noteCounts['noteWriter'],
'totalNotes', noteCounts['totalNotes']], i, count)
else: else:
printLine(json.dumps(cleanJSON(noteCounts), ensure_ascii=False, sort_keys=True)) printLine(json.dumps(cleanJSON(noteCounts), ensure_ascii=False, sort_keys=True))
else: else:
row = {'User': user, 'noteOwner': noteCounts['noteOwner'], 'noteWriter': noteCounts['noteWriter']} row = {'User': user, 'noteOwner': noteCounts['noteOwner'], 'noteWriter': noteCounts['noteWriter'],
'totalNotes': noteCounts['totalNotes']}
if not FJQC.formatJSON: if not FJQC.formatJSON:
csvPF.WriteRowTitles(row) csvPF.WriteRowTitles(row)
elif csvPF.CheckRowTitles(row): elif csvPF.CheckRowTitles(row):
row = {'User': noteCounts.pop('User')} row = {'User': noteCounts.pop('User')}
row['JSON'] = json.dumps(cleanJSON(noteCounts), ensure_ascii=False, sort_keys=True) row['JSON'] = json.dumps(cleanJSON(noteCounts), ensure_ascii=False, sort_keys=True)
csvPF.WriteRowNoFilter(row) csvPF.WriteRowNoFilter(row)
continue elif not csvPF:
if not csvPF:
jcount = len(notes) jcount = len(notes)
if not FJQC.formatJSON: if not FJQC.formatJSON:
entityPerformActionNumItems([Ent.USER, user], jcount, Ent.NOTE, i, count) entityPerformActionNumItems([Ent.USER, user], jcount, Ent.NOTE, i, count)