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

Activity index #9603

Merged
merged 16 commits into from
Nov 29, 2021
Merged

Activity index #9603

merged 16 commits into from
Nov 29, 2021

Conversation

thelostone-mc
Copy link
Member

@thelostone-mc thelostone-mc commented Oct 20, 2021

Description
  • Introduces ActivityIndex to mimic rolling window for Activity
  • Has a cronjob that removes ActivityIndexes older than 400 days
  • Have a helper function which populates ActivityIndex for last 400 days of activity
  • Updates the backend to ensure ActivityIndex is created when Activity is created
  • Updates the read calls to rely on ActivityIndex to fetch activities (would need help in figuring out a nicer way to do this @owocki @gdixon )

TO POPULATE INDEX

from dashboard.management.commands.cleanup_activity_index import *
port_activity_to_index()

Type of ActivityIndex

  • tip:<id>
  • hackathon:<id>
  • bounty:<id>
  • kudo:<id>
  • grant:<id>
  • profile:<id>
  • project:<id>

Revisit Usage

  • get_various_activities L4288
  • reassemble_profile_dict
  • psave_answer
  • HackathonProjectSerializer
  • video_presence
  • def api(request, activity_id):
  • def get_param_metadata(request, tab):
  • increment_view_counts
  • get_specific_activities
  • get_activities
  • hackathon_project_page
  • project_data
  • def quickstart(request):

Flows Tested to make sure ActivityIndex is populated

  • Tips
  • Bounty
  • Grant
  • Kudos
  • Hackathon
  • Project
  • Profile (error when you run out of results -> seems to be an exisiting error)
  • Townsquare

return Activity.objects.filter(
hidden=False, activity_type__in=['wall_post', 'status_update']
Copy link
Contributor

Choose a reason for hiding this comment

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

alternatively you could do this in one query activities_index__key__startswith='profile'

@@ -183,7 +185,10 @@ class ActivitySitemap(Sitemap):
limit = 5000

def items(self):
return Activity.objects.order_by('-pk').cache()
activity_indexes = ActivityIndex.objects.all().values_list('activity__pk', flat=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

id be interested in if this does 2 queries or 1 and if 2 which is more efficient.

options={
'abstract': False,
},
),
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a migration to backport all of the old activities?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup this should do that

image

@owocki
Copy link
Contributor

owocki commented Oct 25, 2021

looks like its getting close . ill be curious if its actually more performant in a production-like setting.

lets move forward on this!

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.

3 participants