uberfastman / fantasy-football-metrics-weekly-report

Command line application to create weekly reports (containing stats, metrics, and rankings) for Fantasy Football leagues on the following platforms: Yahoo, Fleaflicker, Sleeper, ESPN.
GNU General Public License v3.0
179 stars 43 forks source link

[Bug] Weekly report fails to generate for 32 team league #177

Closed garrlker closed 1 year ago

garrlker commented 1 year ago

Description of Issue

When I try to generate a weekly report for a 32 team league I'm in, the tool seems to fail while drawing charts.

Additional Information as Applicable

I'm able to generate weekly reports for all of my other leagues. The only difference in this league is it is by far the biggest

Logs

~~~~~ WEEK 1 METRICS INFO ~~~~~
              SCORE tie(s): 0
COACHING EFFICIENCY tie(s): 4

2022-09-19 18:40:52,445 - report.pdf.generator - INFO - generating PDF (The-Nutter-Butters(846882932579762176)_week-1_report.pdf)...
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/reportlab/graphics/widgetbase.py", line 219, in __getattr__
    return self.__class__.__bases__[0].__getattr__(self,name)
AttributeError: type object 'LinePlotProperties' has no attribute '__getattr__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/main.py", line 282, in <module>
    report_pdf = report.create_pdf_report()
  File "/app/report/builder.py", line 407, in create_pdf_report
    file_for_upload = pdf_generator.generate_pdf(filename_with_path, line_chart_data_list)
  File "/app/report/pdf/generator.py", line 1627, in generate_pdf
    doc.build(elements, onLaterPages=self.add_page_number)
  File "/usr/local/lib/python3.9/site-packages/reportlab/platypus/doctemplate.py", line 1317, in build
    BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
  File "/usr/local/lib/python3.9/site-packages/reportlab/platypus/doctemplate.py", line 1082, in build
    self.handle_flowable(flowables)
  File "/usr/local/lib/python3.9/site-packages/reportlab/platypus/doctemplate.py", line 945, in handle_flowable
    if not frame.add(S[0], canv, trySplit=0):
  File "/usr/local/lib/python3.9/site-packages/reportlab/platypus/frames.py", line 212, in _add
    flowable.drawOn(canv, self._x + self._leftExtraIndent, y, _sW=aW-w)
  File "/usr/local/lib/python3.9/site-packages/reportlab/platypus/flowables.py", line 112, in drawOn
    self._drawOn(canvas)
  File "/usr/local/lib/python3.9/site-packages/reportlab/platypus/flowables.py", line 93, in _drawOn
    self.draw()#this is the bit you overload
  File "/usr/local/lib/python3.9/site-packages/reportlab/graphics/shapes.py", line 647, in draw
    renderPDF.draw(self, self.canv, 0, 0,
  File "/usr/local/lib/python3.9/site-packages/reportlab/graphics/renderPDF.py", line 30, in draw
    R.draw(renderScaledDrawing(drawing), canvas, x, y, showBoundary=showBoundary)
  File "/usr/local/lib/python3.9/site-packages/reportlab/graphics/renderbase.py", line 186, in draw
    self.drawNode(drawing)
  File "/usr/local/lib/python3.9/site-packages/reportlab/graphics/renderPDF.py", line 55, in drawNode
    self.drawNodeDispatcher(node)
  File "/usr/local/lib/python3.9/site-packages/reportlab/graphics/renderbase.py", line 267, in drawNodeDispatcher
    self.drawGroup(node)
  File "/usr/local/lib/python3.9/site-packages/reportlab/graphics/renderbase.py", line 286, in drawGroup
    node = _expandUserNode(node,canvas)
  File "/usr/local/lib/python3.9/site-packages/reportlab/graphics/renderbase.py", line 147, in _expandUserNode
    node = node.provideNode()
  File "/usr/local/lib/python3.9/site-packages/reportlab/graphics/widgetbase.py", line 151, in provideNode
    return self.draw()
  File "/usr/local/lib/python3.9/site-packages/reportlab/graphics/charts/legends.py", line 489, in draw
    c = chart.makeSwatchSample(getattr(col,'index',i),swatchX,swatchY,dx,dy)
  File "/usr/local/lib/python3.9/site-packages/reportlab/graphics/charts/linecharts.py", line 45, in makeSwatchSample
    color = style.strokeColor
  File "/usr/local/lib/python3.9/site-packages/reportlab/graphics/widgetbase.py", line 228, in __getattr__
    return getattr(parent,name)
  File "/usr/local/lib/python3.9/site-packages/reportlab/graphics/widgetbase.py", line 289, in __getattr__
    return getattr(self._value,name)
AttributeError: 'LinePlotProperties' object has no attribute 'strokeColor'

Fantasy Football Platform

Sleeper

League ID

846882932579762176

Operating System

macOS

Other

I'm attaching my config.ini file (renamed to config.txt due to Github allowed filetypes)

config.txt

uberfastman commented 1 year ago

@garrlker thanks so much for reporting this. I definitely did not imagine the edge case where people might use the report for such a large league.

Thankfully I knew where the issue was, as I had only hard-coded 20 unique colors for the line charts, so anything over 20 was always going to break. I've gone ahead and pushed a fix in v13.0.2, so you should be able to pull that down and I confirmed it runs for that ginormous Sleeper league of yours.

I do think some elements look bad/wonky with the huge league, so I might try reducing the font size in the config to maybe help things look slightly better.

garrlker commented 1 year ago

That is awesome! I can confirm that this is working great and the league is very excited, tysm!