Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Cluster Meta Data#208

Open
buralp wants to merge 13 commits intomasterfrom
cluster-meta-data
Open

Cluster Meta Data#208
buralp wants to merge 13 commits intomasterfrom
cluster-meta-data

Conversation

@buralp
Copy link
Contributor

@buralp buralp commented Jul 29, 2021

  • Added new feature named Cluster Meta Data to reach information that Energy Capacity, Registered Customers, Connected Meters on Mini Grid.
  • Created ClusterMetaDataListener.php to listen customer and meter events (created, deleted).
    • increment registered customers count after added a new customer.
    • decrement registered customers count after deleted a customer.
    • increment connected meters count after added a new meter.
    • decrement connected meters count after deleted a meter.
  • Created test files and tested all methods

@93Kamuran
Copy link
Contributor

Please add explain what kind of changes you did with this PR.

public function store(StoreMiniGridRequest $request): ApiResource
{
$miniGrid = $this->miniGrid::create($request->only('cluster_id', 'name'));
event('increment.connected.meters.count');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buralp cluster_meta.connected_meters.increase would be a better name for it.

Please build your events like

  1. base object (cluster_meta, address, person, ....)
  2. property (name, gender, meter_id, ....)
  3. intension ( increase, change, decrease, ..... )


class ClusterMetaData extends Model
{
protected $guarded = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buralp Please use ´BaseModel instead of ´Model.

'\App\Listeners\ClusterMetaDataListener@incrementConnectedMetersCount'
);
$events->listen(
'cluster_meta.connected_meters.decrement',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buralp please use decrease instead of decrement

$meter->save();
}

event('cluster_meta.connected_meters.decrement', $meterParameter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buralp same here : decrease

*/

if ($person->is_customer == 1) {
event('cluster_meta.registered_customers.decrement', $person);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buralp same decrease

}

/** @test */
public function delete_cluster_meta_data_object_after_deleted_a_miniGrid()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are testing if eloquents delete function.

You are deleting ClusterMetaData object and expect that is deleted 🤔 .

What I understand from the function is; After you delete a mini-grid, the ClusterMetaDataobject will also be automatically deleted. Am I right?

Copy link
Contributor Author

@buralp buralp Aug 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes you right. my mistake, i am changing ClusterMetaData to MiniGrid

{
use RefreshDatabase;

/** @test */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buralp please remove @test and add test_ prefix to each function name

}

/** @test */
public function decrement_connected_meters_count_after_deleted_a_meter()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buralp please use decrease instead of decrement


class ClusterMetaDataListener
{
public function incrementConnectedMetersCount(MeterParameter $meterParameter): void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buralp increase would be a better naming. Please change all increment 's with increase .

'birth_date' => $this->faker->date(),
'sex' => $this->faker->randomKey(['male', 'female']),
'is_customer' => 1,
'is_customer' => 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buralp What was the reason to change that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because i want to check that is customer in PersonObserver.php

@buralp buralp force-pushed the cluster-meta-data branch from 36a5989 to 4f402ee Compare August 9, 2021 14:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants