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

Feature/assessment dashboard statistics fix #1402

Conversation

sudan45
Copy link
Contributor

@sudan45 sudan45 commented Dec 28, 2023

Changes

  • Assessment Dashboard registry statistices
    • total assessment count
    • total stakeholder count
    • collection technique count
    • multisector and single sector assessment

This PR doesn't introduce any:

  • temporary files, auto-generated files or secret keys
  • n+1 queries
  • flake8 issues
  • print
  • typos
  • unwanted comments

This PR contains valid:

  • tests
  • permission checks (tests here too)
  • translations

Existing PR: #1341

@sudan45 sudan45 force-pushed the feature/assessment-dashboard-statistics-fix branch 3 times, most recently from dd6ee5f to ee36f15 Compare December 29, 2023 05:22
deep/settings.py Outdated
@@ -109,6 +109,7 @@
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env('DJANGO_SECRET_KEY')

DATA_UPLOAD_MAX_NUMBER_FIELDS = None
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove this

Comment on lines 87 to 95
list_display = ('id', 'project', 'lead', 'created_at', 'publication_date')
readonly_fields = ('created_at', 'modified_at')
autocomplete_fields = (
'created_by',
'modified_by',
'project',
'bg_countries',
'locations',
)
Copy link
Member

Choose a reason for hiding this comment

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

We will need to add this as well. Can you confirm with @Rup-Narayan-Rajbanshi

class StakeHolderInline(admin.TabularInline):
model = AssessmentRegistryOrganization
extra = 0
exclude = ('created_by', 'modified_by')
Copy link
Member

Choose a reason for hiding this comment

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

Maybe use readonly_fields here as well instead of exclude.

@@ -42,6 +43,7 @@ def queryset(self, request, queryset):
class OrganizationFilterSet(django_filters.FilterSet):
search = django_filters.CharFilter(method='search_filter')
used_in_project = IDFilter(method='filter_used_in_project')
Copy link
Member

Choose a reason for hiding this comment

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

We will need to update this to used_in_project_by_lead

deep/schema.py Outdated
@@ -47,6 +47,7 @@ class Query(
assessment_registry_schema.Query,
# --
graphene.ObjectType

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

Comment on lines 292 to 294
admin_level_id = graphene.Int(required=True)
region = graphene.Int(required=True)
geo_area = graphene.Int(required=True)
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
admin_level_id = graphene.Int(required=True)
region = graphene.Int(required=True)
geo_area = graphene.Int(required=True)
admin_level_id = graphene.ID(required=True)
region = graphene.ID(required=True)
geo_area = graphene.ID(required=True)

return (
root.assessment_registry_qs.values("coordinated_joint")
.annotate(count=Count("coordinated_joint"))
.order_by("coordinated_joint")
Copy link
Member

Choose a reason for hiding this comment

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

Missing values()

Comment on lines 463 to 477
stakeholder_counts = defaultdict(int)
organization_type_fields = ["stakeholders__organization_type__title"]

for field in organization_type_fields:
stakeholders = root.assessment_registry_qs.values(field)
for stakeholder in stakeholders:
if organization_type_title := stakeholder.get(field):
stakeholder_counts[organization_type_title] += 1
return [
StakeholderCountType(
stakeholder=org_type_title,
count=count,
)
for org_type_title, count in stakeholder_counts.items()
]
Copy link
Member

Choose a reason for hiding this comment

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

Can you revisit this, we now only have a single table. Let's optimize this query.

return (
root.methodology_attribute_qs.values("data_collection_technique")
.annotate(count=Count("data_collection_technique"))
.order_by("data_collection_technique")
Copy link
Member

Choose a reason for hiding this comment

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

Missing values()

admin_level_id=models.F("locations__admin_level_id"),
code=models.F("locations__code"),
)
.order_by("locations")
Copy link
Member

Choose a reason for hiding this comment

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

Missing values()

@sudan45 sudan45 force-pushed the feature/assessment-dashboard-statistics-fix branch from de28ff5 to 663f045 Compare January 8, 2024 05:06
@AdityaKhatri AdityaKhatri force-pushed the feature/assessment-dashboard-statistics-fix branch from 663f045 to bfd6a7c Compare January 16, 2024 04:33
@sudan45 sudan45 force-pushed the feature/assessment-dashboard-statistics-fix branch from bfd6a7c to 2d088a5 Compare January 18, 2024 10:53
sudan45 and others added 22 commits January 18, 2024 16:43
- total assessment count
- total stakeholder count
- collection technique count
- multisector and single sector assessment
- filter with affected groups
- filter with location,family,frequency,coordination_type,assessment_type and focus
- schema added
- number of assessment according to geographical area
- assessment by all time implemented
- assessment per geographic area completed  and so on
- assessment_per_sector_and_geoarea implemented
- assessment_by_lead_organization implemented and so on
 -total assessment
 -total collection technique
 -total multisector assessment
 -total singlesector assessment
 -collection technique test cases implemented
- assessment per unit of reporting implemented
- assessment per sampling approach implemented
- assessment per proxmity  implemented
…ted ie

  -data collection techniques
  -sampling approach
  -proximity
  -unit of analysis
  -unit of reporting
- location key  changed into geo_id
- region key  is added in the query
- minor error fixes
- geo_id chages into geoid(objects)
 -Median Quality Score by Geographical Area
 -Median Quality score Over Time
 -Median Score for Each Quality Dimension
Dataloader for the Organization
    -Optimized the queryset
    -implemented unit tests
@sudan45 sudan45 force-pushed the feature/assessment-dashboard-statistics-fix branch from 2d088a5 to ee31ee5 Compare January 18, 2024 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants