abr 6, 20218:37 AM - editado abr 6, 202110:30 AM
Top colaborador(a)
Show number of matching rows as a number
Apologies if this has been asked already, but I cannot find any information that can help me solve this.
I am building a custom website module that references the rows within HubDB. It will display how many rows meet a set criteria such as the location (example below).
Number of Sites located in Bowgreave = {{ no_sites }} <!-- correctly shows 44 -->
Since the above worked, I decided to use it as a guide and instead tried using a date column to see how many meetings are on a specific date, but unfortunately it didn't work! (see below)
Show number of meetings with this date = {{ no_dates }} <!--Should show 10 -->
Placing the date inside a text field within HubDB and removing the datetimeformat from the above code seemed to work, but the moment it's placed within a date field and using the above datetime code, nothing displays! I assume I've not coded it correctly to compensate for this field type, but as yet I'm unable to figure it out. Does anyone know what I'm doing wrong?
@alyssamwilie, unfortunately neither solution worked, but I think your on the right track with this. I've used similar methods in the past, but never with date fields.
I'll keep working at it but in the meantime if you have any other ideas please let me know.
First of all, I do not know why, but I have associated that gorilla avatar exclusively with you even though many other people are randomly assigned it. (is it random, I forget)
But you don't give a darn about that.
The reason it is not working is that I don't think you can use that datetime filter there. I won't be able to tell you the technical reason. Probably because it is just an array at this point and you are not targeting the value 🤔
I haven't had the time to work out the human readable filter part, but hopefully this gets you started. Maybe @Anton or @alyssamwilie who are both better at this than I am can take over
{% set date = hubdb_table_rows(4024615) %}
{% set dated = date|selectattr("dated") %}
{% for row in dated %}
{% set test = 1617667200000 %}
{% if row.dated == test && loop.last %}
There are {{ loop.length }} rows in this table with {{test|datetimeformat('%e/%m/%Y')}} as the date<br>
{% endif %}
{% endfor %}