Categories
Mastering Development

Include inside include in sequelize

Basically I have a model called UserLadder that includes another model called User: try { const leaderboard = await UserLadder.findAll({ where: { weeklyLadderId: req.params.id, }, limit: req.params.playersNumber, attributes: [‘userPoints’], include: [{ model: User, attributes: [‘displayName’, ‘profilePicture’] }], order: [[‘userPoints’, ‘DESC’]], }); res.json(leaderboard); } catch (error) { console.error(error); res.status(500).send(‘Server Error.’); } result: [ { "userPoints": 132.5, […]

Categories
Mastering Development

Use Material-UI HOC in Class Component

I’m trying to use material UI in my class component, instead of converting everything to Hooks. I’m not sure which method is easier, Hooks or retro-fitting what I have. Here’s my code: class App extends Component { constructor(props) { super(props); this.state = { hits: [], desc: [], }; } componentDidMount() { this.fetchData(); } fetchData() { […]

Categories
Mastering Development

Search and group by sale status in laravel

it turns out that my search does work, but now I want to group by state and sum. this is my method $ventas = Venta::join(‘personas’,’ventas.idcliente’,’=’,’personas.id’) ->join(‘users’,’ventas.idusuario’,’=’,’users.id’) ->select(‘ventas.id’,’ventas.tipo_comprobante’, ‘ventas.created_at’,’efectivo’,’tarjeta’,’vales’,’ventas.total’, ‘ventas.estado’,’personas.nombre’,’users.usuario’) ->where(‘ventas.’.$criterio, ‘like’, ‘%’. $buscar . ‘%’) ->where(‘ventas.estado’,’=’,’Venta Registrada’) ->orderBy(‘ventas.id’, ‘desc’)

Categories
Mastering Development

What is the best way to approach chaining callbacks in javascript / typescript

I want to have a single endpoint that does this: Create House and store in the database. When we know it has been stored in the database, we create pricing for it, saved to the database as well. Then query the Pricing Table using “type_of_room”, get the average of price, and use the price to […]

Categories
Mastering Development

Select multiple images from camera and convert image to Base64

I am capturing multiple images from camera and showing them into gridview then converting image into base64 format and storing it into local DB. In another activity i need to get this base64 from sqlite and convert back to byte array and i want to display all images into gridview. i am able to display […]

Categories
CMS Magento Mastering Development

Magento 2 All products with uploaded images first sort

I have 100 products. but already completed 20 products of image uploading.now i want to display already uploaed images first. any one help me. i already use this method but not working $this->getLoadedProductCollection()->setOrder(‘image’/or small_image/, ‘desc’)

Categories
Mastering Development

Laravel Voyager, How to translate table using eloquent Model

This below is the sample code for translate, but it’s not translate for field com_id. anyone if you have any solution please help me, Thank you !! <?php namespace App; use Illuminate\Database\Eloquent\Model; use TCG\Voyager\Traits\Translatable; class Job extends Model { protected $table = ‘jobs’; use Translatable; protected $translatable = [‘title’, ‘desc’,’gender’]; public function company() { return […]

Categories
CMS Drupal Mastering Development

entityQuery in Drupal 8

I’ve been working with entityQuery to return nodes on a view page using query below and it works as it should. I’ve been trying to replicate this on node templates which returns 0 nodes. Is there a difference between using this on pages (page.html.twig) as opposed to (node.html.twig)? Thx $query = \Drupal::entityQuery(‘node’) ->condition(‘status’, 1) ->condition(‘type’, […]

Categories
Linux Mastering Development

remove white space using sed

In the table shown below, I want to delete the white spaces before the ID #, ideally using sed. ID,DESC,PRIORITY, 1178896,SKIP BI UPDATE, Low 1178900,SKIP BI UPDATE, High 1178901,SKIP BI UPDATE, High The output should look like this: ID,DESC,PRIORITY, 1178896,SKIP BI UPDATE, Low 1178900,SKIP BI UPDATE, High 1178901,SKIP BI UPDATE, High

Categories
Mastering Development

DAX Measure to Show Last Status Based on Last Date in a Filter

I pulling data from a Jira database into a Power BI report for Scrum sprint metrics. I’m trying to display the last status an issue was in when the sprint ended. I have two Measures created — one that shows the last date an issue status was changed in a sprint and another that I […]