Git Product home page Git Product logo

Comments (3)

qlands avatar qlands commented on June 5, 2024

Likes, posts, views, etc. are activities defined in https://www.w3.org/TR/activitystreams-core/#model.

So, for example, you can state with ElasticFeeds that UserA[actor] posted[activity] XYZ[object] and then UserB[actor] likes[activity] XYZ[object].

Then have a look at this aggregator: elasticfeeds/aggregators/recenttypeobject.py and see if that would give you "UserA, userB and 7 others liked your post." based on the object ID of you "XYZ post".

Aggregators are just classes that encapsulate ElasticSearch queries. As long as you declare Activities, Actor, and Objects, you can query them as you like. With Elasticsearch, you can query which actors liked[verbe] a post[object] ordered by date and return only the details of two but give you the total. With that information, you can construct "UserA, userB, and 7 others liked your post."

from elasticfeeds.

wweevv-johndpope avatar wweevv-johndpope commented on June 5, 2024

cool - thanks

I did some wrangling in chatgpt and got this
https://chat.openai.com/share/6ecf6c1b-acad-4511-ae7f-2a69f0e68bf7
I see also these a whole suit of aggregation functions - have to dig into
https://logz.io/blog/elasticsearch-aggregations/#syntax

I'm planning to deploy to aws / opensearch shortly.
we should bump the elasticsearch to 8.

def generate_abbreviated_highlight(actor_names, verb, object_, total_actors):
    if total_actors == 1:
        return f"{actor_names[0]} {verb} {object_}."
    elif total_actors == 2:
        return f"{actor_names[0]} and {actor_names[1]} {verb} {object_}."
    else:
        remaining_count = total_actors - 2
        return f"{actor_names[0]}, {actor_names[1]} and {remaining_count} others {verb} {object_}."

# Initialize a dictionary to store summarized activities
summarized_activities = {}

# Example list of activities (replace this with your actual activity data)
activities = [
    {"actor": "UserA", "verb": "liked", "object": "your post"},
    {"actor": "UserB", "verb": "liked", "object": "your post"},
    {"actor": "UserC", "verb": "liked", "object": "your post"},
    # Add more activities here
]

# Summarize the activities
for activity in activities:
    actor = activity["actor"]
    verb = activity["verb"]
    object_ = activity["object"]
    
    if (verb, object_) in summarized_activities:
        summarized_activities[(verb, object_)]["actors"].append(actor)
        summarized_activities[(verb, object_)]["count"] += 1
    else:
        summarized_activities[(verb, object_)] = {"actors": [actor], "count": 1}

# Generate and print the summarized highlights
for (verb, object_), data in summarized_activities.items():
    actor_names = data["actors"]
    total_actors = data["count"]
    highlight = generate_abbreviated_highlight(actor_names, verb, object_, total_actors)
    print(highlight)

from elasticfeeds.

johndpope avatar johndpope commented on June 5, 2024

I got around most problems just adding index= to some calls in manager.
this fork is broken - I used elk docker maybe should have persisted with the docker in here - but mines working.
johndpope@e00b0e9

going to look crafting html / that can show some feeds.

from elasticfeeds.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.