Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(analytics): org level analytics #4530

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Conversation

JeevaRamu0104
Copy link
Contributor

@JeevaRamu0104 JeevaRamu0104 commented May 3, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Have an organisation level analytics view:

  1. Combined analytics for the organisation with data of respective merchants
  2. Merchant_id / name becomes a filter in this view

image

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@JeevaRamu0104 JeevaRamu0104 requested review from a team as code owners May 3, 2024 07:15
@JeevaRamu0104 JeevaRamu0104 self-assigned this May 3, 2024
@JeevaRamu0104 JeevaRamu0104 added S-in-progress Status: Implementation is underway A-Analytics labels May 3, 2024
Comment on lines 45 to 52
let mut matching_values = vec![];

for m in org_merchant_ids {
let t = m.clone();
if payload.contains(&t) {
matching_values.push(t);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let mut matching_values = vec![];
for m in org_merchant_ids {
let t = m.clone();
if payload.contains(&t) {
matching_values.push(t);
}
}
let matching_values = payload.iter().filter(|i| org_merchant_ids.contains(i)).cloned().collect();

Comment on lines +390 to +401
let merchant_id: Option<String> = row.try_get("merchant_id").or_else(|e| match e {
ColumnNotFound(_) => Ok(Default::default()),
e => Err(e),
})?;
Ok(Self {
currency,
status,
connector,
authentication_type,
payment_method,
payment_method_type,
merchant_id,
Copy link
Member

Choose a reason for hiding this comment

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

Add this deserialization handler for PaymentMetricRow & PaymentDistributionRow as well

.map(|org| org.merchant_id.clone())
.collect(),
),
_ => None,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_ => None,
_ => vec![&merchant.merchant_id.clone()],

if the user doesn't have org admin access return only a single merchant id that he is belongs to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it need to be none or in the every iteration it will try to push the merchant_id when the permission is not matching

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Analytics S-in-progress Status: Implementation is underway
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Analytics - Organisation view
2 participants