Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Offline
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
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
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
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
Re: RFC: extracting distinct values
gaekwad wrote #326326:
There’s far more prior art for
foo="bar"
thanfoo(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
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
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 withfoo(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
Re: RFC: extracting distinct values
etc wrote #326329:
which other SQL aggregate functions could be useful? Currently we have
max, min, sum, avg
.
Just count
to add from that list, I think. Unless you reckon that’s adequately covered elsewhere. The rest are a bit esoteric and statistics-driven to be of much use, imo.
The only other outliers are:
group_concat()
but since you have to use groups for that, we’re starting to get into seriously convoluted tag territory.json_*
because someone might want to pull out json-formatted content in future. But since we’re only targeting article tags here and don’t store JSON data yet, this might be overkill now.
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
Re: RFC: extracting distinct values
Bloke wrote #326330:
Just
count
to add from that list, I think. Unless you reckon that’s adequately covered elsewhere.
count
is already available, but not as fields value: max(posted)
is a date and can be output via <txp:posted />
, but not count(posted)
.
group_concat()
but since you have to use groups for that, we’re starting to get into seriously convoluted tag territory.
We actually already do GROUP BY
, so adding group_concat()
is not a problem, but I doubt of its utility.
json_*
because someone might want to pull out json-formatted content in future. But since we’re only targeting article tags here and don’t store JSON data yet, this might be overkill now.
They look promising, but are available in MySQL 5.7.22+ only, do we require this?
Offline
Re: RFC: extracting distinct values
FWIW, GROUP_CONCAT(field SEPARATOR ',')
is available now (4.8.5) as list(field)
. It’s yet time to change list
for concat
or join
or ..?
Offline