Skip to content

Add: Gif tracking for profile statistics and getProfileStats()#7019

Merged
vadi2 merged 3 commits intoMudlet:developmentfrom
guhitb:development
Dec 6, 2023
Merged

Add: Gif tracking for profile statistics and getProfileStats()#7019
vadi2 merged 3 commits intoMudlet:developmentfrom
guhitb:development

Conversation

@guhitb
Copy link
Copy Markdown
Contributor

@guhitb guhitb commented Dec 4, 2023

Brief overview of PR changes/additions

  • Created GifTracker to monitor each QMovie created with setMovie()
  • Updated Profile statistics to display gif usage
  • Updated Lua getProfileStats() to include gif usage

Motivation for adding to Mudlet

Statistics should measure Gifs, they are expensive

Other info (issues closed, discussion etc)

/claim #5924

@guhitb guhitb requested a review from a team December 4, 2023 03:39
@guhitb guhitb requested a review from a team as a code owner December 4, 2023 03:39
@guhitb guhitb requested review from a team December 4, 2023 03:39
@guhitb guhitb changed the title Added gif tracking for profile statistics and getProfileStats() Add: Gif tracking for profile statistics and getProfileStats() Dec 4, 2023
@guhitb
Copy link
Copy Markdown
Contributor Author

guhitb commented Dec 4, 2023

Not sure how the copyright headers work. CodeFactor result No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" (legal/copyright) What do I need to add to fix this?

@SlySven
Copy link
Copy Markdown
Member

SlySven commented Dec 4, 2023

Not sure how the copyright headers work. CodeFactor result No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" (legal/copyright) What do I need to add to fix this?

If you take a look at the cpp or h files in the ./template subdirectory of the Git repository you will find sample headers (like the ones you have used for those two new files) and they have this at the top of the text inside the "box":

/***************************************************************************
 *   Copyright (C) YEAR by NAME - EMAIL                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *

You just have to replace YEAR with this year (2023), NAME with your Real Name and EMAIL with a currently usable EMail address that, theoretically can be used to contact you if necessary. Since this is publicly available you might want to use a free one that you don't mind being spammed senseless on when it gets scraped - OTOH My ISP is reasonably good at blocking them and I use an EMail client that enables me to check the headers of any messages that look dodgy that get by that filtering.

Each year that you modify a file you are supposed to update the date ranges - I'm fairly good at doing that myself but some other contributors don't seem to bother, possibly, some maintain, this is because they can be identified from the Git history of the project. To see what this looks like you might like to consider the TLuaInterpreter.h file - its header is currently:

/***************************************************************************
 *   Copyright (C) 2008-2013 by Heiko Koehn - KoehnHeiko@googlemail.com    *
 *   Copyright (C) 2013-2016, 2018-2023 by Stephen Lyons                   *
 *                                               - slysven@virginmedia.com *
 *   Copyright (C) 2014 by Ahmed Charles - acharles@outlook.com            *
 *   Copyright (C) 2016-2018 by Ian Adkins - ieadkins@gmail.com            *
 *   Copyright (C) 2017 by Chris Reid - WackyWormer@hotmail.com            *
 *                                                                         *

@guhitb
Copy link
Copy Markdown
Contributor Author

guhitb commented Dec 4, 2023

Thanks for your help 😄

@guhitb
Copy link
Copy Markdown
Contributor Author

guhitb commented Dec 5, 2023

I've tested it by placing this script on a button

local saveto = getMudletHomeDir().."/kymip.gif"
local url = "https://media.tenor.com/n3qkDYO5jbMAAAAi/doge.gif"

if downloadHandler then killAnonymousEventHandler(downloadHandler) end
downloadHandler = registerAnonymousEventHandler("sysDownloadDone",
  function(_, filename)
    if filename ~= saveto then
      return true
    end
    
    local width, height = getImageSize(saveto)

    local x = math.random(0, 500)
    local y = math.random(0, 500)
    local name = string.rep("a",x)
    createLabel(name, x, y, width, height, 0)
    setMovie(name, saveto)
    setLabelReleaseCallback(name, function()
      if math.random() <0.5 then
        echo("Removing Gif\n")
        deleteLabel(name)
      else
        echo("Pausing Gif\n")
        pauseMovie(name)
      end
    end)
  end, true)
  

local pfs = getProfileStats()
echo("getProfileStats().gifs.active: ")
echo(getProfileStats().gifs.active)
echo("\ngetProfileStats().gifs().total: ")
echo(getProfileStats().gifs.total)
echo("\n")

echo("Adding Gif\n")
downloadFile(saveto, url)
mudlet-.3.mp4

Is this correct?

Copy link
Copy Markdown
Member

@vadi2 vadi2 left a comment

Choose a reason for hiding this comment

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

I love it :)

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Dec 6, 2023

/create links

@vadi2 vadi2 merged commit d981a17 into Mudlet:development Dec 6, 2023
@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Dec 10, 2023

/tip $80 @guhitb

@algora-pbc
Copy link
Copy Markdown

algora-pbc bot commented Dec 10, 2023

@algora-pbc
Copy link
Copy Markdown

algora-pbc bot commented Dec 10, 2023

🎉🎈 @guhitb has been awarded $80! 🎈🎊

vadi2 pushed a commit to vadi2/Mudlet that referenced this pull request Dec 24, 2023
…t#7019)

<!-- Keep the title short & concise so anyone non-technical can
understand it,
     the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
- Created GifTracker to monitor each QMovie created with setMovie()
- Updated Profile statistics to display gif usage
- Updated Lua getProfileStats() to include gif usage
#### Motivation for adding to Mudlet
Statistics should measure Gifs, they are expensive
#### Other info (issues closed, discussion etc)
/claim Mudlet#5924
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants