-
-
Save parzibyte/cdce99bddc094a0fc9885ee6918f166e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (d *DatosGraficasController) productosMasVendidos(fechaInicio, fechaFin string) []ProductoVendidoParaGrafica { | |
// Nota: "masVendidosContado" se usa para mezclar tanto los vendidos al contado como apartados, se usa para evitar declarar un temporal | |
masVendidosApartados := d.productosMasVendidosEnApartados(fechaInicio, fechaFin) | |
masVendidosContado := d.productosMasVendidosAlContado(fechaInicio, fechaFin) | |
for _, producto := range masVendidosApartados { | |
indice := existeProducto(masVendidosContado, producto) | |
if indice != -1 { | |
masVendidosContado[indice].VecesVendido += producto.VecesVendido | |
} else { | |
masVendidosContado = append(masVendidosContado, producto) | |
} | |
} | |
quicksort(&masVendidosContado, 0, int64(len(masVendidosContado)-1)) | |
if len(masVendidosContado) > LimiteProductosMasVendidos { | |
return masVendidosContado[:LimiteProductosMasVendidos] | |
} else { | |
return masVendidosContado | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment