Skip to content

Conversation

@imilinovic
Copy link
Contributor

@imilinovic imilinovic commented Jul 18, 2023

Description

Implemented collections.avg query module procedure and added tests for it.

Pull request type

  • Bugfix
  • Algorithm/Module
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

######################################

Reviewer checklist (the reviewer checks this part)

Module/Algorithm

######################################

@imilinovic imilinovic self-assigned this Jul 18, 2023
@imilinovic imilinovic changed the title add collections avg and tests for it [E-ivan-add-collections] < [T410-MAGE-implement-avg] Add collections.avg procedure Jul 18, 2023
@imilinovic imilinovic marked this pull request as draft July 18, 2023 14:35
Copy link
Contributor

@antoniofilipovic antoniofilipovic left a comment

Choose a reason for hiding this comment

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

Looks good, few comments about style.

Comment on lines 5 to 9
constexpr const char *kProcedureAvg = "avg";

constexpr const char *kReturnAvg = "average";

constexpr const char *kNumbersList = "list_of_numbers";
Copy link
Contributor

Choose a reason for hiding this comment

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

use on these constexpr std::string_view asconst char *is a global that may change.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would move these globals to hpp if possible, otherwise keep all either in cpp or hpp.


void Avg(mgp_list *args, mgp_graph *memgraph_graph, mgp_result *result, mgp_memory *memory);

} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

This red circle on GitHub means that you are missing an empty line at the end of the file. Practice is on our side to always have an empty line after the last line in the file.

CALL collections.avg([-5, 5, 2.2, -8.6, 0, 1.0])
YIELD average;
output:
- average: -0.8999999999999999 No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

The empty line is missing here too and on some other files. Add empty line please on other files to

const auto &list = arguments[0].ValueList();

for (const auto list_item : list){
if(!list_item.IsNumeric())
Copy link
Contributor

Choose a reason for hiding this comment

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

add {} for this if. It is style generally in MAGE

const auto record_factory = mgp::RecordFactory(result);

try {
double average = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
double average = 0;
double average{0};

@antoniofilipovic
Copy link
Contributor

@imilinovic sorry your PR is still in draft but I left couple of comments for later :D

@antoniofilipovic antoniofilipovic added the status: change PR reviewed - needs changes label Jul 19, 2023
@imilinovic imilinovic removed the status: change PR reviewed - needs changes label Jul 21, 2023
@imilinovic imilinovic changed the title [E-ivan-add-collections] < [T410-MAGE-implement-avg] Add collections.avg procedure [E-ivan < T410] Implement collections.avg Jul 24, 2023
@imilinovic imilinovic added the status: ready PR is ready for review label Jul 24, 2023
@imilinovic imilinovic marked this pull request as ready for review July 24, 2023 20:07
Copy link
Contributor

@antoniofilipovic antoniofilipovic left a comment

Choose a reason for hiding this comment

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

Good to go

@antoniofilipovic antoniofilipovic added status: ship it PR approved and removed status: ready PR is ready for review labels Jul 25, 2023
@imilinovic imilinovic merged commit 685113c into E-ivan-add-collections Jul 25, 2023
@imilinovic imilinovic deleted the T410-MAGE-implement-avg branch July 25, 2023 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: ship it PR approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants