Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2020-10-10 10:06:59

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,370
Website

Re: RFC: extracting distinct values

etc wrote #326311:

No :-) because it should be applicable to any field, not only dates, e.g. max(comments_count).

The only other one I can think of is fresh and stale


Wondrous Healing Wondrous ways to a healthy old age
Safe Reiki Harmless natural healing.
Gud One Blog

Offline

#12 2020-10-10 18:07:05

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 3,169

Re: RFC: extracting distinct values

etc wrote #326298:

all distinct (authorid, posted) pairs will be output, not only the most recent one. Currently the problem is solved via

<txp:article_custom time="-1 year" fields="authorid, posted=max" sort="Posted DESC">...

The question is: is posted=max syntax clear enough? What would you suggest otherwise?

If only the most recent value is desired, could limit be deployed in article_custom? The fields pair is defined, the sort gets the most recent and limit does its thing…or am I missing something?

Offline

#13 2020-10-10 18:17:01

etc
Developer
Registered: 2010-11-11
Posts: 3,934
Website

Re: RFC: extracting distinct values

gaekwad wrote #326319:

If only the most recent value is desired, could limit be deployed in article_custom?

We want the most recent value for each author:

Donald Duck (2020-02-02)
Donald Swain (2002-02-20)
...

Offline

#14 2020-10-10 18:23:50

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 3,169

Re: RFC: extracting distinct values

etc wrote #326322:

We want the most recent value for each author:

Ah. Yes, of course.

The type of person doing this kind of tag soup is not the average Textpattern-er, so personally I’d err towards going with what terminology you think is most appropriate given your intentions for other article data, and we can explain it with examples in the docs pages.

(My 2 shekels.)

Offline

#15 2020-10-10 18:48:52

etc
Developer
Registered: 2010-11-11
Posts: 3,934
Website

Re: RFC: extracting distinct values

gaekwad wrote #326323:

The type of person doing this kind of tag soup is not the average Textpattern-er

Oh, this beverage is rather popular: limit categories to the current section, etc. Anyway, the question is not semantics (max is a right name, I think) but syntax:

posted=max, max(posted) or something else?

Offline

#16 2020-10-10 18:57:17

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,776
Website

Re: RFC: extracting distinct values

It’ll be MAX(posted) for me. It’s more SQLish and we’re dealing with SQL inside these fields in the same way we can currently use FIELD(column, value1, value2, value3) inside sort. It feels more consistent.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#17 2020-10-10 18:57:38

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 3,169

Re: RFC: extracting distinct values

etc wrote #326324:

posted=max, max(posted) or something else?...

There’s far more prior art for foo="bar" than foo(bar), so given the A/B choice I’d choose the former.

Edit: actually, Stef’s right – ignore me.

Last edited by gaekwad (2020-10-10 18:58:46)

Offline

#18 2020-10-10 18:58:26

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,776
Website

Re: RFC: extracting distinct values

gaekwad wrote #326326:

There’s far more prior art for foo="bar" than foo(bar), so given the A/B choice I’d choose the former.

Haha! I just chose the opposite. But I get what you mean. Hmmmm. Torn. It’s more attributey but then if we’re not using quotes, it might be confusing for people that are used to using them in regular attributes, to have to omit them here.

Last edited by Bloke (2020-10-10 19:00:36)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#19 2020-10-10 19:04:08

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 3,169

Re: RFC: extracting distinct values

Bloke wrote #326327:

I just chose the opposite. But I get what you mean.

Tag stuff is fairly well-defined with plenty of foo="bar" formatting, but I totally see your point. I guess it depends on whether you want to introduce something that’s a bit different into tag markup that makes it a more complex.

I would wager most people don’t do this kind of stuff, but the kind who do would be comfortable with either option, given sufficient explanation in the relevant doc(s). As you say, it’s database extraction speak, not HTML-like markup…is there a precedent for tag stuff with foo(bar) constructs already?

Offline

#20 2020-10-10 19:12:26

etc
Developer
Registered: 2010-11-11
Posts: 3,934
Website

Re: RFC: extracting distinct values

gaekwad wrote #326328:

Tag stuff is fairly well-defined with plenty of foo="bar" formatting…is there a precedent for tag stuff with foo(bar) constructs already?

Be it posted=max or max(posted), it’s not an attribute but a value:

fields="authorid, max(posted), sum(comments_count)"

And while we are there, which other SQL aggregate functions could be useful? Currently we have max, min, sum, avg.

Offline

Board footer

Powered by FluxBB