theming – How to count number of published nodes of a specific content type in twig template?

I’m looking for a way to achieve this in my Twig file; if the number of published entities of a content type ‘promotions’ is at least one, a certain entity should be displayed in a content type Shop. I’m trying to show a banner only if there is at least one published promotion entity.

I could use some help with the if-function. I’ve written it down with I’m trying to do.

if(published promotion entities > 0){
{{ drupal_entity('node', 2668) }}
}

Any ideas to get me going? Thanks!

Can I fix Reallocated Sectors Count and Current Pending Sector Count?

I have problem(Caution) with Reallocated Sectors Count and Current Pending Sector Count. I detected this problem after running CrystalDiskInfo, knowing that Iam using hp laptop running windows10. Any suggestion to solve this problem?

dnd 5e – Does Flesh to Stone count the first saving throw?

Based on how the paragraph is written, I would say the first failure does not count.

Let’s break it down:

A creature restrained by this spell must make another Constitution saving throw at the end of each of its turns.

This only affects creatures restrained by the spell. So it is implied that there has been one failed save.

If it successfully saves against this spell three times, the spell ends. If it fails its saves three times, it is turned to stone and subjected to the petrified condition for the duration.

The creature must now make three successful saves to break out of the restraint/spell. The wording is, “If it successfully saves against this spell three times”. It then uses the same wording, “If it fails its saves three times,” with regards to failing saves. This would imply that the initial failure is no longer a concern. This condition wouldn’t even matter if they passed the initial save.

If the first failure counted, then the phrase would have been “If it fails its save twice more”, or something to that effect. The key being “more”; a reference to the earlier failure. Lacking any reference, both implied or directly, would seem to indicate that the creature is starting from zero.

Also keep in mind, that this would be the same mechanism as death saving throws and the Contagion spell; best 3 out of 5.

sql – Como usar distinct Count y Join en codeigniter entre 2 Base de Datos

Hola necesito llevar esta consulta SQL a codeigniter

SELECT Count(DISTINCT uh.carrera.alumno_id)
From alumno.listado
Inner Join uh.carrera ON uh.carrera.alumno_id = alumno.listado.id

La consulta en SQL funciona perfectamente, lo que no se hacer la relación entre 2 base de datos en codeigniter, he probado muchas variantes pero ninguna con resultados, todas con errores, el objetivo es contar la cantidad de alumnos que hay en esa universidad.

python – Problemas com método count em uma queryset do django

Saudações,

Eu estou com uma situação estranha com o django e o método count, eu tenho uma queryset que eu chamei de intervalos e então tenho uma variável qtd_intervalo onde eu armazeno o intervalos.count() aí faço os testes:
if qtd_intervalo > 1:
if qtd_intervalo ==1:

        qtd_intervalos = intervalos.count()
        if qtd_intervalos > 1:
            #se existem intervalos em aberto então eu irei finalizalos e pronto
            intervalos.update(finalizada = True,data_finalizacao = agora,data_final=agora,usuario_edicao = usuario)
            _horario_final = "{0}:{1}".format(agora.hour,agora.minute)
            usuario.flags('em_trabalho') = True
            usuario.flags('em_intervalo') = False
            usuario.save()
            _html = _FECHAR_PONTO + _ABRIR_INTERVALO
            return {"sucesso":True,'html':_html,
                    "mensagem":"Foram finalizados {0} intervalos às {1}".format(qtd_intervalos,_horario_final)}
        elif qtd_intervalos == 1:
            _hora_inicio = intervalos(0).data_inicial
            _horario_inicio = "{0}:{1}".format(_hora_inicio.hour,_hora_inicio.minute)
            _horario_final = "{0}:{1}".format(agora.hour,agora.minute)
            intervalos.update(finalizada = True,data_finalizacao = agora,data_final=agora,usuario_edicao = usuario)
            usuario.flags('em_trabalho') = True
            usuario.flags('em_intervalo') = False
            usuario.save()
            _html = _FECHAR_PONTO + _ABRIR_INTERVALO
            return {"sucesso":True,'html':_html,
                    "mensagem":"Foi finalizado o intervalo aberto em {0} às {1}".format(_horario_inicio,_horario_final)}
        else:
            intervalo = Calendario(dependencia = calendario_ponto,usuario = usuario)
            _data_final = agora + relativedelta(minutes=30)
            nome = "Intervalo de {0}".format(usuario)
            descricao = "Intervalo: {0}".format(agora)
            flags = {'cancelada':False,'lida':False,
                'situacao_finalizacao':{"status":"aguardando início",'cor':'gray','icone':"fa fa-hourglass-o fa-2x",
                                        'icone_normal':"fa fa-hourglass-o",'estilo':'default',},
                'percentual':0,"ponto":True,"intervalo":True,"em_servico":False}

etc.

Mas vez ou outra dentro deste if eu recebo o erro:

File “/home/caaorg/caaorg/institucional/models.py” in
abrir_fechar_intervalo
4374. _hora_inicio = intervalos(0).data_inicial

File
“/home/caaorg/virtual-caaorg/lib/python3.7/site-packages/django/db/models/query.py”
in getitem
309. return qs._result_cache(0)

Exception Type: IndexError at
/contabilidade/alterar-estado-meu-intervalo/ Exception Value: list
index out of range

Que não faz sentido porque eu verifiquei antes se a quantidade de itens na queryset é maior que zero…

Django 2.2.16 e python 3.7

Alguém tem ideia do que pode ser isso?

performance – Suddenly SQL server restarted with pending task count increased

We are trying to understand the issue where SQL server was suddenly restarted on its own-

Its a SQL server 2012 SP4 -GDR applied with 40 CPu’s HT enabled , thus total of 80 logical processors-

From error logs we found

/**********************/

BEGIN stack Dump

Non- Yielding Scheduler
/**********************/

Error messages just at the time of restart of SQL. Also there was no mini dump created as checked.

Yes we have quite some queries running at that time. Top 3 waits seen were:-

1.TranLogIO
2.CXPACKET
3.PAGELATCH SH

However we also noticed wait called SOS WORKER as collected from system health XE which i believe is nothing else but THREADPOOL. Therefore i went further and analyse the query processing details from that system health and found at the time of non yielding scheduler errors below was logged

At 19:46 maxworkers– 2944 workers created 789 oldest pending taskwait time 0 pending task 4

At 19:51 maxworkers– 2944 workers created 982 oldest pending taskwait time 256987 pending task 165

At 19:51 we started seeing restart happened.

Question is why there would be a threadpool wait if almost 2000 workers are still available from above calculation. Also why those pending task count 165 when queries have so many schedulers available to run and complete the request for bunch of queries waiting on CXPACKETS?

Thanks

database design – ınner joın two tables and count some variables

I have two tables
-ERHAN_FLASH
-ERHAN_FLASH_NAME

ERHAN_FLASH:
COMPANY CONTENTNUMBER
TELEKOM 11146
TELEKOM 11146
TELEKOM 11146
TELEKOM 11146
TELEKOM 11146
TELEKOM 11147
TELEKOM 11147
TELEKOM 11147
TELEKOM 11147
TELEKOM 11147

ERHAN_FLASH_NAME:
EGIA_CONTENT_NAME   EGI_CONTENT_CODE
Keyif Veren Sunum   510
Musteri Odakli icerik Yonetimi  2467
Temel Yonetim Becerileri    2469
Veritabani Dosyalama Sistemleri 2889
Sunum   2890

EGI_CONTENT_CODE equals CONTENTNUMBER

I need to count these table like 

CONTENTNUMBER EGIA_CONTENT_NAME  COUNT
11146          CONTENT1          146
11147          CONTENT2           42
12456          NULL               12

but some variables IN ERHAN_FLASH_NAME EGI_CONTENT_CODE is null

how can I join these 2 tables and count

How to get top 5 highest CPU consuming processes and their thread count using powershell command

How to get top 5 highest CPU consuming processes and their thread count using powershell command?

Need values of CPU, ProcessName, PID, Thread count

dynamic programming – Count subset divisible by 3

I’m trying to solve this puzzle but I get stucked. I thought about trying to use the law of total probability to solve intermediate problems with subset of size k but it didn’t helped me that much. Is anyone kind enough to give me the right approach to solve this ?

Problem: You are given N boxes indexed from 1 to N. The number of boxes with 0, 1, or 2 coins is n0, n1, and n2, respectively. The number of empty boxes and the number of boxes with one coin are denoted by n0 and n1, n2 respectively. You take a random subset of the boxes where each subset has the same same probability to be selected. The empty set and the set itself are considered a subset.

What is the probability that the total number of coins in a random subset is divisible by 3.

Entity Framework Core verify SaveChanges count

I am using ASP.NET Core 3.1 and have been assigned a task to verify the count of changes done using SaveChanges().
It is expected that the developer should know how many records will be changed before-hand when SaveChanges() will be called.

To implement it, I have created an extension method for DbContext called SaveChangesAndVerify(int expectedChangeCount) where I am using transaction and equating this parameter with the return value of SaveChanges().
If the values match, the transaction is committed and if it doesn’t match, the transaction is rolled back.

Please check the code below and let me know if it would work and if there are any considerations that I need to make. Also, is there a better way to do this?

public static class DbContextExtensions
{
    public static int SaveChangesAndVerify(this DbContext context, int expectedChangeCount)
    {
        context.Database.BeginTransaction();
        var actualChangeCount = context.SaveChanges();
        if (actualChangeCount == expectedChangeCount)
        {
            context.Database.CommitTransaction();
            return actualChangeCount;
        }
        else
        {
            context.Database.RollbackTransaction();
            throw new DbUpdateException($"Expected count {expectedChangeCount} did not match actual count {actualChangeCount} while saving the changes.");
        }
    }

    public static async Task<int> SaveChangesAndVerifyAsync(this DbContext context, int expectedChangeCount, CancellationToken cancellationToken = default)
    {
        await context.Database.BeginTransactionAsync();
        var actualChangeCount = await context.SaveChangesAsync();
        if(actualChangeCount == expectedChangeCount)
        {
            context.Database.CommitTransaction();
            return actualChangeCount;
        }
        else
        {
            context.Database.RollbackTransaction();
            throw new DbUpdateException($"Expected count {expectedChangeCount} did not match actual count {actualChangeCount} while saving the changes.");
        }
    }
}

A sample usage would be like context.SaveChangesAndVerify(1) where a developer is expecting only 1 record to update.