diff --git a/phosta b/phosta

index 19a8a5638ee9780cfadcbaef50f5f9229e9eb295..c081de33f652a16cb7e53fe7b5a95c1bf13f444c 100755

--- a/phosta

+++ b/phosta

@@ -18,7 +18,7 @@ use Data::Dumper;

$Getopt::Std::STANDARD_HELP_VERSION = 'true';

-my $VERSION = '1.2';

+my $VERSION = '1.3';

my $PROGRAM = 'phosta';

my $configfile = catfile(File::HomeDir->my_home, '.phosta.conf');

@@ -69,9 +69,13 @@ exit 0;

sub validate

{

- my @group_params = ('year', 'month', 'week', 'hour');

- !defined($opt_g) || grep /$opt_g/, @group_params or return 0;

-

+ my @group_params = ('year', 'month', 'week', 'dayofmonth', 'dayofweek', 'hour');

+ if (defined($opt_g)) {

+ foreach (split (/,/, $opt_g)) {

+ my $val = $_;

+ grep /$val/, @group_params or return 0;

+ }

+ }

my @select_params = qw(file maker model lensmaker lens aperture exposuretime iso focallength focallength35mm);

if (defined($opt_s)) {

foreach (split (/,/, $opt_s)) {

@@ -237,25 +241,34 @@ my $fieldlist = '';

my @grouparray;

my $orderlist = '';

my @wherearray;

- given ($opt_g) {

- when ('month') {

- $fieldlist = "IFNULL(strftime('%Y/%m', datetimeoriginal), '-') as month,";

- push @grouparray, "strftime('%Y/%m', datetimeoriginal)";

- }

- when ('week') {

- $fieldlist = "IFNULL(strftime('%Y/%W', datetimeoriginal), '-') as week,";

- push @grouparray, "strftime('%Y/%W', datetimeoriginal)";

- }

- when ('year') {

- $fieldlist = "IFNULL(strftime('%Y', datetimeoriginal), '-') as year,";

- push @grouparray, "strftime('%Y', datetimeoriginal)";

- }

- when ('hour') {

- $fieldlist = "IFNULL(strftime('%H', datetimeoriginal), '-') as hour,";

- push @grouparray, "strftime('%H', datetimeoriginal)";

+ foreach (split (/,/, $opt_g)) {

+ given ($_) {

+ when ('month') {

+ $fieldlist = $fieldlist . "IFNULL(strftime('%m', datetimeoriginal), '-') as month,";

+ push @grouparray, "strftime('%m', datetimeoriginal)";

+ }

+ when ('week') {

+ $fieldlist = $fieldlist . "IFNULL(strftime('%W', datetimeoriginal), '-') as week,";

+ push @grouparray, "strftime('%W', datetimeoriginal)";

+ }

+ when ('year') {

+ $fieldlist = $fieldlist . "IFNULL(strftime('%Y', datetimeoriginal), '-') as year,";

+ push @grouparray, "strftime('%Y', datetimeoriginal)";

+ }

+ when ('hour') {

+ $fieldlist = $fieldlist . "IFNULL(strftime('%H', datetimeoriginal), '-') as hour,";

+ push @grouparray, "strftime('%H', datetimeoriginal)";

+ }

+ when ('dayofmonth') {

+ $fieldlist = $fieldlist . "IFNULL(strftime('%d', datetimeoriginal), '-') as dayofmonth,";

+ push @grouparray, "strftime('%d', datetimeoriginal)";

+ }

+ when ('dayofweek') {

+ $fieldlist = $fieldlist . "substr('SunMonTueWedThuFriSat-', 1+ 3 * IFNULL(strftime('%w', datetimeoriginal), 7), 3) as dayofweek,";

+ push @grouparray, "strftime('%w', datetimeoriginal)";

+ }

}

}

-

if (defined($opt_s)) {

$fieldlist = $fieldlist . $opt_s. ', ';

push @grouparray, $opt_s;

@@ -456,7 +469,7 @@ say ' only media files which match (case-insensitive!) the given extensions are added to the database';

say '';

say 'stats querying:';

say ' -g <period> : group by a time period, defaults to total (which means no grouping by period)';

- say ' allowed values: year, month, week, hour';

+ say ' allowed values: year, month, week, dayofmonth, dayofweek, hour';

say ' -s <fields> : specify the information you want to select, defaults to none (just show number of images)';

say ' allowed values: file, maker, model, lensmaker, lens, aperture, exposuretime, iso, focallength, focallength35mm';

say ' multiple fields should be listed comma-separated without whitespaces';

diff --git a/phosta-completion.sh b/phosta-completion.sh

index a584b4bdd4c810c51311123ab7197481275ebc8b..203c95af1ae775180e76c3043503032c4656e2c5 100644

--- a/phosta-completion.sh

+++ b/phosta-completion.sh

@@ -4,12 +4,12 @@ _phosta_completions()

{

local cur=${COMP_WORDS[COMP_CWORD]}

local prev=${COMP_WORDS[COMP_CWORD-1]}

+ local suggestions=""

local prefix=""

if [[ ${cur} =~ "," ]]; then

prefix="${cur%,*},"

fi

- local suggestions=""

case "${prev}" in

"-o")

suggestions=($(compgen -W "${prefix}year ${prefix}month ${prefix}week ${prefix}hour ${prefix}file ${prefix}maker ${prefix}model ${prefix}lensmaker ${prefix}lens ${prefix}aperture ${prefix}exposuretime ${prefix}iso ${prefix}focallength ${prefix}focallength35mm" "${cur}"))

@@ -18,13 +18,13 @@ "-s")

suggestions=($(compgen -W "${prefix}file ${prefix}maker ${prefix}model ${prefix}lensmaker ${prefix}lens ${prefix}aperture ${prefix}exposuretime ${prefix}iso ${prefix}focallength ${prefix}focallength35mm" "${cur}"))

;;

"-g")

- suggestions=($(compgen -W "${prefix}year ${prefix}month ${prefix}week ${prefix}hour" "${cur}"))

+ suggestions=($(compgen -W "${prefix}year ${prefix}month ${prefix}week ${prefix}dayofmonth ${prefix}dayofweek ${prefix}hour" "${cur}"))

;;

"-T")

suggestions=($(compgen -W "auto on off" "${cur}"))

;;

"-n")

- suggestions=($(compgen -W "10 20 50 100" "${cur}"))

+ suggestions=($(compgen -W "1 3 5 10 20 50 100" "${cur}"))

;;

"-W")

suggestions=($(compgen -W "80 100 120" "${cur}"))

@@ -41,6 +41,9 @@ suggestions=($(compgen -d "${cur}"))

;;

"-D")

suggestions=($(compgen -f "${cur}"))

+ ;;

+ *)

+ suggestions=($(compgen -W "-o -s -g -T -n -W -t -p -D -c -E -e -f -n"))

;;

esac

diff --git a/phosta-examples.7.scd b/phosta-examples.7.scd

index aad78c2a1521c00ef04d39172a4bf5c623c9a875..a298655906f4e7aa12896b31b2746ae1253fa548 100644

--- a/phosta-examples.7.scd

+++ b/phosta-examples.7.scd

@@ -17,7 +17,7 @@

## QUERY DATA

- show image count by _model_ in 2019 grouped by month, sorted by newest month first

```

-phosta -s model -g month -t 20190101-20121231 -o month,count

+phosta -s model -g month -t 20190101-20191231 -o month,count

```

- show image count by _model_ for _make_ FUJIFILM grouped by year, ordered by year & count descending

diff --git a/phosta.1.scd b/phosta.1.scd

index 5cf4f85fa709d32744aa5fbc802137d9e477f637..dada2dd16b9cca0c2f95f21dbc5563c3f0cc70a6 100644

--- a/phosta.1.scd

+++ b/phosta.1.scd

@@ -84,7 +84,7 @@

*-g* <period>

Group result set by a time period.++

Default: total (which means no grouping by period)++

-Allowed values: _year_, _month_, _week_, _hour_

+Allowed values: _year_, _month_, _week_, _dayofmonth_, _dayofweek_, _hour_

*-n* <number>

Limit the resultset to <number> of lines.