You are viewing a single comment's thread from:

RE: [ENG/ITA] Python and Hive: Learning from Other Hiveans!

in Olio di Balena2 months ago (edited)

I was aware that it open and close a file, but I didn't know it could be used for different tasks, like databases and http sessions: a knowledge worth remembering... and mastering :)

btw did you manage to use condenser's get_accounts function?

Today I tried a bit the condenser_api.get_discussions_by_author_before_date, because I needed to see what info were submitted when publishing a post... and after that I started experimenting a bit 😅

def get_discussions_before_date(url, num, session: requests.Session):
    data = f'{{"jsonrpc":"2.0", "method":"condenser_api.get_discussions_by_author_before_date", "params":["arc7icwolf","","2024-09-12T22:49:43",{num}], "id":1}}'
    response = get_response(data, url, session)
    discussions = response.json()['result']
    reputation_list = []
    for discussion in discussions:
        reputation = discussion['author_reputation']
        if reputation not in reputation_list:
            reputation_list.append(reputation)
    return reputation_list

And here is when I found that my reputation hasn't changed with the last 100 posts I published 😂

EDIT: unless I made a mistake, because now I'm trying to change the date and it keeps giving me the same results as before:

import requests

def get_response(data, url, session: requests.Session):
    request = requests.Request("POST", url=url, data=data).prepare()
    response = session.send(request, allow_redirects=False)
    return response

def get_discussions_before_date(url, num):
    with requests.Session() as session:
        data = f'{{"jsonrpc":"2.0", "method":"condenser_api.get_discussions_by_author_before_date", "params":["arc7icwolf","","2024-07-29T12:23:09",{num}], "id":1}}'
        response = get_response(data, url, session)
        discussions = response.json()['result']
        reputation_list = []
        for discussion in discussions:
            print(discussion)
            reputation = discussion['title']
            if reputation not in reputation_list:
                reputation_list.append(reputation)
        return reputation_list


def main():
    url = "https://api.deathwing.me"
    num = 3
    rep_list = get_discussions_before_date(url, num)
    print(rep_list)


if __name__ == "__main__":

    main()

No matter what date I set, I always see the data and title about my last 3 posts... I guess I'll try to understand what I messed up tomorrow after a good sleep 😴

Sort:  

Condenser provides 'higher level' information. The further you deviate from the core functions of Hive, the more complicated (and unreliable) it gets.
Reputation for example is abstracted. It never was a core feature of Hive, but was built on top of it.

And here is when I found that my reputation hasn't changed with the last 100 posts I published 😂

Whenever you get a vote (up or down) it affects your reputation.
So yeah, something went wrong.

I am not familiar with all calls in the documentation.
I have never touched get_discussions_by_author_before_date
There's also no guarantee that the calls are properly documented and I raged about that a while ago:
https://peakd.com/dev/@felixxx/hive-api-reference-incomplete
I have since been told that the documentation is incomplete on purpose, because the higher level (hivemind) stuff, will be abandoned in the future in favor of a HAF infrastructure.

I am pretty sure there is no extra table that saves how high your reputation was at a given time. That would be a very long database table that makes an entry after every vote you ever received and that for every user... too much data for too little benefit...

I could look into the above call more closely, depending on how important it is for you.

Generally, I'd say: stay away from get_discussion and anything reputation for now. They are soft.
block_api, account_api are core features and the most reliable...

I have since been told that the documentation is incomplete on purpose

What an unusual purpose LOL also considering that I guess that this situation is going on since a long time, and this doesn't sound like something which could help increase adoption...

I could look into the above call more closely, depending on how important it is for you.

Don't worry, I chose that key only to see if was able to access it, but I could have chosen a different one! oc I had to choose one that wasn't working properly among all the available keys 🤣

Generally, I'd say: stay away from get_discussion and anything reputation for now. They are soft.

Gotcha!

Well...

I actually went ahead an wrote a whole post about it...

Already seen and upvoted! :) Happy to see you posting more snippets and useful tips! As soon as I can I will read again it and use it to make more progress with my coding.