Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

Commit

Permalink
fix: rate raid after last PR (#114)
Browse files Browse the repository at this point in the history
* After adding last minute changes there were few leftovers
* Regenerate docs
  • Loading branch information
tripledes committed Dec 28, 2019
1 parent adae645 commit f950edf
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 14 deletions.
Binary file modified doc/build/doctrees/application.doctree
Binary file not shown.
Binary file modified doc/build/doctrees/domain.doctree
Binary file not shown.
Binary file modified doc/build/doctrees/environment.pickle
Binary file not shown.
2 changes: 1 addition & 1 deletion doc/build/html/application.html
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ <h2>Raid<a class="headerlink" href="#raid" title="Permalink to this headline">¶
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<em>String</em>) – Raid’s given name.</p></li>
<li><p><strong>date</strong> (<em>datetime.datetime</em>) – Date and time for the Raid.</p></li>
<li><p><strong>date</strong> (<em>String</em>) – Date and time for the Raid.</p></li>
<li><p><strong>location</strong> (<em>String</em>) – Location of the Raid.</p></li>
<li><p><strong>gang_id</strong> (<em>Integer</em>) – Id of the Gang where the Raid is being organized.</p></li>
<li><p><strong>sheriff_id</strong> (<em>Integer</em>) – Id of the Sheriff organizing the Raid.</p></li>
Expand Down
6 changes: 3 additions & 3 deletions doc/build/html/domain.html
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ <h2>Raid<a class="headerlink" href="#raid" title="Permalink to this headline">¶
<li><p><strong>sheriff</strong> (<a class="reference internal" href="#thesheriff.domain.outlaw.sheriff.Sheriff" title="thesheriff.domain.outlaw.sheriff.Sheriff"><em>Sheriff</em></a>) – The Raid organizer.</p></li>
<li><p><strong>gang</strong> (<a class="reference internal" href="#thesheriff.domain.gang.gang.Gang" title="thesheriff.domain.gang.gang.Gang"><em>Gang</em></a>) – Gang where the raid is organized.</p></li>
<li><p><strong>location</strong> (<em>String</em>) – Restaurant location.</p></li>
<li><p><strong>date</strong> (<em>datetime.datetime</em>) – Date and time when the raid happens.</p></li>
<li><p><strong>date</strong> (<em>String</em>) – Date and time when the raid happens.</p></li>
<li><p><strong>raid_id</strong> (<em>Integer</em>) – Optional, Raid Id.</p></li>
<li><p><strong>rates</strong> – Optional, list with assigned rates.</p></li>
</ul>
Expand Down Expand Up @@ -436,7 +436,7 @@ <h2>Raid<a class="headerlink" href="#raid" title="Permalink to this headline">¶
<dd><p>Class RaidFactory produces Raids.</p>
<dl class="method">
<dt id="thesheriff.domain.raid.raid_factory.RaidFactory.create">
<em class="property">static </em><code class="sig-name descname">create</code><span class="sig-paren">(</span><em class="sig-param">name: str, members: List[thesheriff.domain.outlaw.outlaw.Outlaw], sheriff: thesheriff.domain.outlaw.sheriff.Sheriff, gang: thesheriff.domain.gang.gang.Gang, location: str, date: datetime.datetime, raid_id: Optional[int] = None, rates: Optional[List[float]] = []</em><span class="sig-paren">)</span> &#x2192; thesheriff.domain.raid.raid.Raid<a class="headerlink" href="#thesheriff.domain.raid.raid_factory.RaidFactory.create" title="Permalink to this definition"></a></dt>
<em class="property">static </em><code class="sig-name descname">create</code><span class="sig-paren">(</span><em class="sig-param">name: str, members: List[thesheriff.domain.outlaw.outlaw.Outlaw], sheriff: thesheriff.domain.outlaw.sheriff.Sheriff, gang: thesheriff.domain.gang.gang.Gang, location: str, date: str, raid_id: Optional[int] = None, rates: Optional[List[float]] = []</em><span class="sig-paren">)</span> &#x2192; thesheriff.domain.raid.raid.Raid<a class="headerlink" href="#thesheriff.domain.raid.raid_factory.RaidFactory.create" title="Permalink to this definition"></a></dt>
<dd><p>Method create, produces a Raid instance.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
Expand All @@ -446,7 +446,7 @@ <h2>Raid<a class="headerlink" href="#raid" title="Permalink to this headline">¶
<li><p><strong>sheriff</strong> (<a class="reference internal" href="#thesheriff.domain.outlaw.sheriff.Sheriff" title="thesheriff.domain.outlaw.sheriff.Sheriff"><em>Sheriff</em></a>) – The Outlaw organizing the Raid.</p></li>
<li><p><strong>gang</strong> (<a class="reference internal" href="#thesheriff.domain.gang.gang.Gang" title="thesheriff.domain.gang.gang.Gang"><em>Gang</em></a>) – Gang this Raid is organized for.</p></li>
<li><p><strong>location</strong> (<em>String</em>) – Location of the raid.</p></li>
<li><p><strong>date</strong> (<em>datetime.datetime</em>) – Raid’s date and time.</p></li>
<li><p><strong>date</strong> (<em>String</em>) – Raid’s date and time.</p></li>
<li><p><strong>raid_id</strong> (<em>Integer</em>) – Optional, Raid’s Id.</p></li>
<li><p><strong>rates</strong> – Optional, list with assigned rates.</p></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion doc/build/html/searchindex.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion thesheriff/application/raid/grade_raid.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def execute(self, raid: Raid) -> float:
grade = 0.0
total = 0.0
divider = float(len(raid.rates))
print("divider:", divider)
if divider > 0.0:
for rate in raid.rates:
total += rate
Expand Down
2 changes: 1 addition & 1 deletion thesheriff/application/raid/request/create_raid_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CreateRaidRequest:
:param name: Raid's given name.
:type name: String
:param date: Date and time for the Raid.
:type date: datetime.datetime
:type date: String
:param location: Location of the Raid.
:type location: String
:param gang_id: Id of the Gang where the Raid is being organized.
Expand Down
2 changes: 1 addition & 1 deletion thesheriff/domain/raid/raid.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Raid:
:param location: Restaurant location.
:type location: String
:param date: Date and time when the raid happens.
:type date: datetime.datetime
:type date: String
:param raid_id: Optional, Raid Id.
:type raid_id: Integer
:param rates: Optional, list with assigned rates.
Expand Down
4 changes: 2 additions & 2 deletions thesheriff/domain/raid/raid_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RaidFactory(Raid):
@staticmethod
def create(
name: str, members: List[Outlaw], sheriff: Sheriff,
gang: Gang, location: str, date: datetime,
gang: Gang, location: str, date: str,
raid_id: Optional[int] = None,
rates: Optional[List[float]] = list()
) -> Raid:
Expand All @@ -30,7 +30,7 @@ def create(
:param location: Location of the raid.
:type location: String
:param date: Raid's date and time.
:type date: datetime.datetime
:type date: String
:param raid_id: Optional, Raid's Id.
:type raid_id: Integer
:param rates: Optional, list with assigned rates.
Expand Down
11 changes: 7 additions & 4 deletions thesheriff/infrastructure/repository/mysql_raid_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
from thesheriff.domain.raid.repository.raid_repository import \
RaidRepository
from thesheriff.domain.outlaw.outlaw_factory import OutlawFactory
from thesheriff.domain.outlaw.sheriff_factory import SheriffFactory
from thesheriff.domain.gang.gang_factory import GangFactory
from thesheriff.domain.outlaw.repository.outlaw_repository import \
OutlawRepository
from sqlalchemy import create_engine, MetaData, Table
from datetime import datetime


class MySQLRaidRepository(RaidRepository):
Expand Down Expand Up @@ -52,17 +54,18 @@ def of_id(self, raid_id: int) -> Raid:

if row.rates:
rates = self.__split_rates(row.rates)
dt_str = datetime.strftime(row.date, Raid.DEFAULT_DATETIME_FORMAT)
outlaw = OutlawFactory.create_with_id(row.sheriff_id)
sheriff = SheriffFactory.create(outlaw)

# TODO:
# create Sheriff
return RaidFactory.create(
raid_id=row.id,
name=row.name,
members=outlaws,
sheriff=None,
sheriff=sheriff,
gang=gang,
location=row.location,
date=row.date,
date=dt_str,
rates=rates
)

Expand Down

0 comments on commit f950edf

Please sign in to comment.