In my project I want to index the data.
The code of views:
- #phones.each.with_index(1) do |(phone,no_of_duplicate),index|
.row.py-2
.col-2 = index
- if no_of_duplicate.count > 1
.col-3 = phone
.col-3 = no_of_duplicate.count
.col-4 .......................................
I obtain the result as
If I change the code on views as:
- #phones.each.with_index(1) do |(phone,no_of_duplicate),index|
- if no_of_duplicate.count > 1
.row.py-2
.col-2 = index
.col-3 = phone
.col-3 = no_of_duplicate.count
The got the result as:
How can I solve this?
You can filter before assigning indexes and rendering:
#phones.filter { |(_,no_of_duplicate)| no_of_duplicate.count > 1 }.each <...>
Related
I have a problem with cubejs library. when i call the method drilldown from a measure.
i was puting the drill members field on my schema but always return null.
this is my measure from the schema
compromisoFinalMuyAlta: {
sql: `
CASE
WHEN (
(sum(
CASE
WHEN (${CUBE}.id_tipo_cobertura = 4 AND ${CUBE}.id_bi_rango_sla = 5) THEN ${CUBE}.total_cuentas_rango
END
) - ${inactivasTotalMuyAlta}) > 0
) THEN ROUND(SUM(
CASE
WHEN (${CUBE}.id_tipo_cobertura = 4 AND ${CUBE}.id_bi_rango_sla = 5) THEN ${CUBE}.total_cuentas_rango
END
)) - ${inactivasTotalMuyAlta}
ELSE 0
END
`,
type: `number`,
title: 'Resultado final',
drillMembers:[`${CUBE}.id_tipo_cobertura`,`${CUBE}.total_cuentas_rango`]
}
this the method what i have the resultset and try to call the drilldown method
public BuscarDetalle(columnValue) {
console.log(this.resultQuery);
const queryDetail = this.resultQuery.drillDown({
xValues: ["0 - 3 días"],
yValues: ["compromiso_real.id_cliente", "SlaCompromisos.compromisoFinalMuyAlta"]
});
console.log(queryDetail);
}
and this is the table from cube.
enter image description here
First of all, Thanks.
Is it possible to hide a facet based on the current table ?
Exemple, I have a "news" table and a table "project".
But if I do this :
facets.state {
label.data = LLL:EXT:skin/Resources/Private/Language/locallang.xlf:search.rfp_state
field = state_intS
renderingInstruction = TEXT
renderingInstruction {
field = optionValue
wrap = {LLL:EXT:projects/Resources/Private/Language/locallang_db.xlf:tx_projects_domain_model_requestforprojects.state.items.|}
insertData = 1
}
includeInAvailableFacets = 0
}
The includeInAvailableFacets is
for both my news and project
Looked into the docs, but couldn't find what i've been looking for...
https://docs.typo3.org/p/apache-solr-for-typo3/solr/master/en-us/Configuration/Reference/TxSolrSearch.html#faceting-facets-facetname-includeinavailablefacets
Got it !
You have to declare condition to your precise page like this :
Where 1772 is your page id. Found a lead here : https://docs.typo3.org/m/typo3/reference-typoscript/8.7/en-us/Conditions/Reference/
[globalVar = TSFE:id =1772] && [globalVar = TSFE:id = {$plugin.tx_anrskin.settings.pages.solrSortDateDesc}] && [globalVar = GP:q =]
plugin.tx_solr.search.query.sortBy = sortDate_dateS desc
plugin.tx_solr.search.sorting = 0
plugin.tx_solr.search.query.returnFields = *, score
plugin.tx_solr.search.faceting.facets.dateinterval.includeInAvailableFacets = 0
plugin.tx_solr.search.faceting.facets.item.includeInAvailableFacets = 0
plugin.tx_solr.search.faceting.facets.name.includeInAvailableFacets = 0
[globalVar]
Context
We have a table with 155 elements,
I want to build this field on every pages,
'Showing result [from starting item - to item number X ] of itemTotal'
StartingItem = 1 -----> at page 1
ItemNumberX = the user can see the next 25 items
this is the actual pages filter
These are data that I actually have
const minShowData = currentPage === 1 ? 1 : (currentPage - 1) * itemsPerPage;
const itemsAtCurrentPage = currentPage * itemsPerPage;
const maxShowData =
totalCount > itemsAtCurrentPage ? itemsAtCurrentPage : totalCount;
const showElement = [5, 10, 20, 25, 50]; ----> this is the old pagination
we have the data itemsPerPage through a reducer, and represent how many items we will see in page, in the second field risultati per pagina is set to 2.
this is how the variable showElement appear
there is a way with these data to made a filter like
Showing results [1-25, 26-50, 51-75 ...] of 155 ?
I don't need the code to build the component, just understand if there is a way to build the computation inside the field
so you have
const itemsPerPage = 25; //this you can set to be user alterable if you want
const itemsTotal = 155; //this you'd use a function to go get the number of items.
const pageIncrements[];
for (let pageNumber = 1; pageNumber <= itemsTotal / itemsPerPage; pageNumber++) {
pageIncrements += [((pageNumber - 1) * (itemsPerPage) + 1)) + " - " + (pageNumber * itemsPerPage)]
}
if (itemsTotal % itemsPerPage > 0) {
pageIncrements += [(itemsTotal - (itemsTotal % itemsPerPage)) + " - " + itemsTotal]
}
Sorry, haven't worked with react syntax, but the logic should be right.
I created sql with enable/disable options with var.sql_server_enable, but I have a problem about output. If the var.sql_server_enable is 0, the azurerm_sql_server.sql_server.name is going to be null and I get the following error.
resource "azurerm_sql_server" "sql_server" {
count = "${var.sql_server_enable ? 1 : 0}"
name = "${var.sql_server_name}"
resource_group_name = "${var.sql_server_resource_group_name}"
location = "${var.sql_server_location}"
version = "${var.sql_server_version}"
administrator_login = "${var.sql_server_admin_user}"
administrator_login_password = "${var.sql_server_admin_pass}"
}
output "sql_server_name_output" {
value = "${var.sql_server_enable == "1" ? azurerm_sql_server.sql_server.name : var.null }"
}
Error: Error running plan: 1 error occurred:
* module.hello.module.azure_sql_server_hello_staging.output.sql_server_name_output: Resource 'azurerm_sql_server.sql_server' not found for variable 'azurerm_sql_server.sql_server.name'
You could output
value = "${var.sql_server_enable ? azurerm_sql_server.sql_server[0].name : var.null }". When you terraform apply, you could type "1" for true, "0" for false when you input values for variable "sql_server_enable".
This works for me with Terraform v0.12.6 + provider.azurerm v1.32.1, you can upgrade it if you need.
variable "sql_server_enable" {
type = bool
}
variable "null" {
default = "this is empty"
}
resource "azurerm_sql_server" "sql_server" {
count = "${var.sql_server_enable ? 1 : 0}"
name = "mysqlserver123qaz"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
version = "12.0"
administrator_login = "mradministrator"
administrator_login_password = "thisIsDog11"
}
output "sql_server_name_output" {
value = "${var.sql_server_enable ? azurerm_sql_server.sql_server[0].name : var.null }"
}
Result1
Result2
Hope this could help you.
Thanks for the answer, but sql_server_name_output variable is used on the other module. It needs string value. Then i use var.null rather than null. After i follow your suggestion, I get another error below. Do you have any other suggestion?
Error: Inconsistent conditional result types
on ../modules/azure_sql_server/output.tf line 9, in output "sql_server_name_output":
9: value = "${var.sql_server_enable ? azurerm_sql_server.sql_server[*].name : var.null }"
|----------------
| azurerm_sql_server.sql_server is tuple with 1 element
| var.null is "null"
| var.sql_server_enable is true
The other resource that needs azurerm_sql_server.sql_server is below.
resource "azurerm_sql_firewall_rule" "sql_firewall_rule" {
count = "${var.sql_fw_enable == "1" ? 1 : 0}"
name = "${var.sql_fw_rule_name}"
resource_group_name = "${var.sql_fw_rule_resource_group_name}"
server_name = "${azurerm_sql_server.sql_server}"
start_ip_address = "${var.sql_fw_rule_start_ip}"
end_ip_address = "${var.sql_fw_rule_end_ip}"
}
I have a curious page structure, colPos = 0 of the subpages is used as content for its parent ... these pages have animations that need code in the parent page footer so I added the field tx_add_animation_code in table tt_content and this code needs to be collected.
setup.txt:
# footer script
page.footerData {
# collect subpages
5 = LOAD_REGISTER
5 {
pageIds.cObject = CONTENT
pageIds.cObject {
table = pages
select {
pidInList = this
recursive = 0
selectFields = uid
where = {#no_search}=0
}
renderObj = TEXT
renderObj {
field = uid
required = 1
wrap = |,
}
}
}
# open javascript
10 = TEXT
10.value (
<script type="text/javascript">
)
# test id collection
25 = TEXT
25 {
data = register:pageIds
noTrimWrap (
|
/* subpage Ids: | */
|
)
}
# collect animation code from CE's on subpages
20 = CONTENT
20 {
table = tt_content
select {
pidInList.data = register:pageIds
# THIS LINE BREAKS FUNCTIONALITY
where = {#colPos}=0
}
renderObj = COA
renderObj {
10 = TEXT
10.stdWrap.field = tx_add_animation_code
}
if {
value = pagets__homepage,pagets__onepage
isInList.data = TSFE:page|backend_layout
}
}
# close javascript
30 = TEXT
30.value (
</script>
)
90 = RESTORE_REGISTER
}
where = {#colPos}=0 breaks the functionality, and if I do not include it, of course, the field is collected from all the content elements ...
what is the issue ?
Please make sure that there are really some Content Elements on the Subpages having colPos=0. Please note that some extensions like gridelements or other multicol extensions will set the colPos of their childelements to something negative like -67 so they won't match the select-statement anymore.