Giter VIP home page Giter VIP logo

dominionstats's Introduction

mikemccllstr-rtd

Top level container for ReadTheDocs integration.

dominionstats's People

Contributors

bricef avatar dlu avatar dorshhh avatar edofthefu avatar kcrca avatar mikemccllstr avatar rrenaud avatar tlstyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dominionstats's Issues

Still have card_info reference in query_matcher.py

In QueryMatcher.__init__(), there is still a reference to card_info.sane_title(). This needs to be updated:

    if 'kingdom' in args:
        self.kingdom_restrict = [card_info.sane_title(k)
                                 for k in args['kingdom'].split(',')]

Maybe more generally, search for other references to card_info that are left over from commit 7d4c46a.

Game search cares about spaces between card names, but it should not

When searching for more than one card in a kingdom, inclusion of a space after the comma separating two card names results in an "internal server error". Ideally, the application should ignore such spaces in this situation.

With no space, Highway,Saboteur, we get a successful search: http://councilroom.com/search_result?p1_name=Qvist&p2_name=&kingdom=Highway%2CSaboteur

With a space between the card names, Highway, Saboteur, we get an internal server error: http://councilroom.com/search_result?p1_name=Qvist&p2_name=&kingdom=Highway%2C+Saboteur

These two URLs should return the same results.

This was reported by Qvist on http://forum.dominionstrategy.com/index.php?topic=6305.0

HTTPS/TLS/SSL?

I notice that https://www.councilroom.com doesn't work, only http://www.councilroom.com.

% nmap www.councilroom.com 
Starting Nmap 7.80 ( https://nmap.org ) at 2023-04-10 21:57 PDT
Nmap scan report for www.councilroom.com (107.23.137.191)
Host is up (0.079s latency).
rDNS record for 107.23.137.191: ec2-107-23-137-191.compute-1.amazonaws.com
Not shown: 998 filtered ports
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 6.72 seconds

I don't suppose you'd be open to enabling HTTPS for the sake of security and privacy? (E.g., ISPs are known to inject ads and tracking into all unencrypted connections.)

I'd be happy to help either in terms of implementation or just advice.

Looking at the README it seems like the Python app is probably just running on a raw VPS somewhere. If that's the case, it's easy to set up HTTPS without even making application changes: just install Caddy and use it as a reverse proxy with this /etc/caddy/Caddyfile:

{
    auto_https disable_redirects
}

https://www.councilroom.com:443 {
    reverse_proxy localhost:80
}

The proxy takes care of solving HTTP-01 challenges and managing the appropriate certs, so you're basically good to go.

If the architecture is something different, there are of course other options that might be better suited. If you already have an nginx or Apache setup, you can set up Certbot to handle the provisioning and renewals, then it's just a matter of updating your proxy config to pull in the cert files from disk. Or if this is on EC2 and you'd prefer to use an Amazon solution, ALBs and classic ELBs will terminate TLS for you via ACM, which can be renewed automatically if your records are in Route 53 as they seem like they might be:

% dog councilroom.com 
SOA councilroom.com. 6m20s A "ns-685.awsdns-21.net." "awsdns-hostmaster.amazon.com." 1 2h00m00s 15m00s 14d0h00m00s 1d0h00m00s

The main disadvantage of that is just that you end up paying around $20/month on load balancer infrastructure for questionable benefit. Anyway, up to you, just thought I would raise the question since I didn't see other discussions about it here or on the mailing list.

Visiting /supply_win, Server 500 error in call to /supply_win_api

Traceback from gunicorn log:

Traceback (most recent call last):
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/application.py", line 239, in process
    return self.handle()
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/application.py", line 230, in handle
    return self._delegate(fn, self.fvars, args)
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/application.py", line 420, in _delegate
    return handle_class(cls)
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/application.py", line 396, in handle_class
    return tocall(*args)
  File "/srv/councilroom/councilroom_prod/frontend.py", line 607, in GET
    target_inds = map(self.str_card_index, targets)
  File "/srv/councilroom/councilroom_prod/frontend.py", line 544, in str_card_index
    return str(card.index)
NameError: global name 'card' is not defined

System running out of memory at times

The update.py script was killed when the system ran out of memory on 2012-12-19:

Dec 19 03:29:30 ip-10-0-0-236 kernel: [11571472.649735] [ pid ]   uid  tgid total_vm      rss cpu oom_adj oom_score_adj name
Dec 19 03:29:30 ip-10-0-0-236 kernel: [11571472.649990] [25456]  1001 25456   272242   216302   0       0             0 python
Dec 19 03:29:30 ip-10-0-0-236 kernel: [11571472.649994] [25501]     0 25501   106609    66276   0       0             0 gunicorn
Dec 19 03:29:30 ip-10-0-0-236 kernel: [11571472.649997] [25537]     0 25537   164450     8463   0       0             0 gunicorn
Dec 19 03:29:30 ip-10-0-0-236 kernel: [11571472.650001] [25547]     0 25547    82500    65622   0       0             0 gunicorn
Dec 19 03:29:30 ip-10-0-0-236 kernel: [11571472.650005] Out of memory: Kill process 25456 (python) score 334 or sacrifice child
Dec 19 03:29:30 ip-10-0-0-236 kernel: [11571472.650018] Killed process 25456 (python) total-vm:1088968kB, anon-rss:865208kB, file-rss:0kB

It died during the optimal_card_ratios step.

Traceback on player page

Traceback (most recent call last):
File "/srv/councilroom/councilroom_working/.venv/local/lib/python2.7/site-packages/web/application.py", line 239, in process
return self.handle()
File "/srv/councilroom/councilroom_working/.venv/local/lib/python2.7/site-packages/web/application.py", line 230, in handle
return self._delegate(fn, self.fvars, args)
File "/srv/councilroom/councilroom_working/.venv/local/lib/python2.7/site-packages/web/application.py", line 420, in _delegate
return handle_class(cls)
File "/srv/councilroom/councilroom_working/.venv/local/lib/python2.7/site-packages/web/application.py", line 396, in handle_class
return tocall(*args)
File "/srv/councilroom/councilroom_working/frontend.py", line 340, in GET
ret += (query_matcher.GameMatcher(g, qm).display_game_snippet() +
File "/srv/councilroom/councilroom_working/query_matcher.py", line 133, in display_game_snippet
self._display_supply())
File "/srv/councilroom/councilroom_working/query_matcher.py", line 126, in _display_supply
_render_card(card, freq, self.query_matcher.kingdom_restrict))
File "/srv/councilroom/councilroom_working/query_matcher.py", line 20, in _render_card
plural = dominioncards.pluralize(freq)
AttributeError: 'module' object has no attribute 'pluralize'

Precalculate more stats for "players" page to improve its performance

From Rob's post in councilroom-dev:

I suspect because a few of the pages are coded very poorly and traverse a whole users set of games to compute stats (popular buys per player, the player page, and the player vs other player record page all do this). When a a similarly poorly coded search engine comes around (these pages are blocked by robots.txt, but some search engines don't honor it), it just keeps putting too many requests on those uber slow pages and councilroom eventually runs out of memory and dies. The decision to do a scan of all the players games came when players had a few hundred game max, but now that there are crazy people with 10k games, and so the design is horribly broken. If someone pre-computed those pages, I am pretty sure a 486 could serve councilroom fine.

Not sure what is required to be precalculated in advance, but it is distinctly slow for users with large game counts.

Precalculate more stats for "popular buys per player" page to improve its performance

From Rob's post in councilroom-dev:

I suspect because a few of the pages are coded very poorly and traverse a whole users set of games to compute stats (popular buys per player, the player page, and the player vs other player record page all do this). When a a similarly poorly coded search engine comes around (these pages are blocked by robots.txt, but some search engines don't honor it), it just keeps putting too many requests on those uber slow pages and councilroom eventually runs out of memory and dies. The decision to do a scan of all the players games came when players had a few hundred game max, but now that there are crazy people with 10k games, and so the design is horribly broken. If someone pre-computed those pages, I am pretty sure a 486 could serve councilroom fine.

Not sure what is required to be precalculated in advance, but it is distinctly slow for users with large game counts.

The /popular_buys page dies with an error when searching for a player

The site returns an internal server error when searching for, say, rrenaud on the /popular_buys page.

This is the traceback from the gunicorn log:

Traceback (most recent call last):
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/application.py", line 239, in process
    return self.handle()
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/application.py", line 230, in handle
    return self._delegate(fn, self.fvars, args)
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/application.py", line 420, in _delegate
    return handle_class(cls)
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/application.py", line 396, in handle_class
    return tocall(*args)
  File "/srv/councilroom/councilroom_prod/frontend.py", line 75, in GET
    return render.buy_template(stats, player_buy_summary)
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/template.py", line 881, in __call__
    return BaseTemplate.__call__(self, *a, **kw)
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/template.py", line 808, in __call__
    return self.t(*a, **kw)
  File "buy_template.html", line 130, in __template__
    </tbody>
  File "/srv/councilroom/councilroom_prod/stats.py", line 112, in render_std_devs
    return u'%.2f' % (self.mean() / self.sample_std_dev())
  File "/srv/councilroom/councilroom_prod/stats.py", line 115, in mean
    return self.mvs1.mean() - self.mvs2.mean()
  File "/srv/councilroom/councilroom_prod/stats.py", line 115, in mean
    return self.mvs1.mean() - self.mvs2.mean()
  File "/srv/councilroom/councilroom_prod/stats.py", line 40, in mean
    return self.sum / self.freq
ZeroDivisionError: integer division or modulo by zero

money() error on display of game log

Recent commit have introduced a new error that occurs on visiting the game logs (http://councilroom.com/game?game_id=game-20130119-160107-0c7d61c4.html):

Error annotating game, tell [email protected]!
Exception:'int' object is not callable
  File "/srv/councilroom/councilroom_prod/frontend.py", line 447, in GET
    return annotate_game.annotate_game(contents, game_id, debug)
  File "/srv/councilroom/councilroom_prod/annotate_game.py", line 56, in annotate_game
    encoded = game_state.encode_game_state()
  File "/srv/councilroom/councilroom_prod/game.py", line 516, in encode_game_state
    'money': self.cur_turn.money() if self.cur_turn else 0,

Precalculate more stats for "player vs other player record" page to improve its performance

From Rob's post in councilroom-dev:

I suspect because a few of the pages are coded very poorly and traverse a whole users set of games to compute stats (popular buys per player, the player page, and the player vs other player record page all do this). When a a similarly poorly coded search engine comes around (these pages are blocked by robots.txt, but some search engines don't honor it), it just keeps putting too many requests on those uber slow pages and councilroom eventually runs out of memory and dies. The decision to do a scan of all the players games came when players had a few hundred game max, but now that there are crazy people with 10k games, and so the design is horribly broken. If someone pre-computed those pages, I am pretty sure a 486 could serve councilroom fine.

Not sure what is required to be precalculated in advance, but it is distinctly slow for users with large game counts.

Internal server error on visiting /openings

gunicorn log:

Traceback (most recent call last):
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/application.py", line 239, in process
    return self.handle()
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/application.py", line 230, in handle
    return self._delegate(fn, self.fvars, args)
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/application.py", line 420, in _delegate
    return handle_class(cls)
  File "/srv/councilroom/councilroom_prod/.venv-prod/local/lib/python2.7/site-packages/web/application.py", line 396, in handle_class
    return tocall(*args)
  File "/srv/councilroom/councilroom_prod/frontend.py", line 127, in GET
    opening['cards'].sort(key=dominioncards.cost, reverse=True)
AttributeError: 'module' object has no attribute 'cost'

Update the isotropic game scraper to leverage the new approach

The scraper script should now:

  1. Retrieve the day's archive from isotropic
  2. Store a verbatim copy in the S3 bucket
  3. Create a Celery task instance to repackage it

The Celery task should:

  1. Retrieve the file from S3
  2. Decompress it
  3. Recompress each game, individually
  4. Insert the compressed game into MongoDB
  5. Create a Celery task instance to parse and insert the game

Don't Blame Rob

Some of the error pages still say to email/blame Rob when things go wrong.

Implement rate limiting for abusive search engines

From Rob's post in councilroom-dev:

I suspect because a few of the pages are coded very poorly and traverse a whole users set of games to compute stats (popular buys per player, the player page, and the player vs other player record page all do this). When a a similarly poorly coded search engine comes around (these pages are blocked by robots.txt, but some search engines don't honor it), it just keeps putting too many requests on those uber slow pages and councilroom eventually runs out of memory and dies. The decision to do a scan of all the players games came when players had a few hundred game max, but now that there are crazy people with 10k games, and so the design is horribly broken. If someone pre-computed those pages, I am pretty sure a 486 could serve councilroom fine.

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.