Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
amadanmath committed Oct 24, 2017
2 parents cd4a219 + bb2394d commit 184732f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion analyser/analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def __init__(self, encounter):
encounter_collector.add_data('start_tick', start_time, int)
encounter_collector.add_data('end_tick', encounter_end, int)
encounter_collector.add_data('duration', (encounter_end - start_time) / 1000, float)
encounter_collector.add_data('cm', self.boss_info.cm_detector(events))
encounter_collector.add_data('cm', self.boss_info.cm_detector(events, self.boss_instids))

encounter_collector.add_data('phase_order', [name for name,start,end in self.phases])
for phase in self.phases:
Expand Down
18 changes: 12 additions & 6 deletions analyser/bosses.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@ class Kind(IntEnum):
DUMMY = 3
FRACTAL = 4

def no_cm(events):
def no_cm(events, boss_instids):
return False

def yes_cm(events):
def yes_cm(events, boss_instids):
return True

def cairn_cm_detector(events):
def cairn_cm_detector(events, boss_instids):
return len(events[events.skillid == 38098]) > 0

def samarog_cm_detector(events):
def samarog_cm_detector(events, boss_instids):
return len(events[(events.skillid == 37966)&(events.time - events.time.min() < 10000)]) > 0

def mo_cm_detector(events, boss_instids):
return len(events[(events.state_change == 12) & (events.dst_agent == 30000000) & (events.src_instid.isin(boss_instids))]) > 0

def deimos_cm_detector(events, boss_instids):
return len(events[(events.state_change == 12) & (events.dst_agent == 42000000) & (events.src_instid.isin(boss_instids))]) > 0

class Metric:
def __init__(self, name, short_name, data_type, split_by_player = True, split_by_phase = False, desired = DesiredValue.LOW):
self.name = name
Expand Down Expand Up @@ -218,7 +224,7 @@ def find_end_time(self,
Metric('Soldiers', 'Soldiers', MetricType.COUNT, False),
Metric('Soldier\'s Aura', 'Soldier AOE', MetricType.COUNT),
Metric('Enemy Tile', 'Enemy Tile', MetricType.COUNT)
]),
], cm_detector = mo_cm_detector),
Boss('Samarog', Kind.RAID, [0x4324], phases = [
Phase("Phase 1", True, phase_end_health = 66, phase_end_damage_stop = 10000),
Phase("First split", False, phase_end_damage_start = 10000),
Expand Down Expand Up @@ -249,7 +255,7 @@ def find_end_time(self,
Metric('Demonic Shockwave', 'Shockwave', MetricType.COUNT, True, False),
Metric('Teleports', 'Teleports', MetricType.COUNT, True, False),
Metric('Tear Consumed', 'Tears Consumed', MetricType.COUNT, True, False)
]),
], cm_detector = deimos_cm_detector),
Boss('Standard Kitty Golem', Kind.DUMMY, [16199]),
Boss('Average Kitty Golem', Kind.DUMMY, [16177]),
Boss('Vital Kitty Golem', Kind.DUMMY, [16198]),
Expand Down
4 changes: 2 additions & 2 deletions gw2raidar/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from dateutil import parser

VERSION = {
'id': '1.0.0',
'timestamp': 1508725674, # date +%s
'id': '1.0.1',
'timestamp': 1508830887, # date +%s
}

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
Expand Down
5 changes: 5 additions & 0 deletions raidar/templates/raidar/info_releasenotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ <h4>
<span class="ignore">released on</span>
[[formatDate(data.version.timestamp)]]
</h4>
<ul>
<li>Added code in preparation for detection of Raid Challenge Mode instances</li>
<li>Changed response status code to 4xx for erroneous API upload requests</li>
</ul>
<h4>Version 1.0.0</h4>
<p>This major release marks a massive milestone for GW2Raidar. Massive thanks to the community for your support, patience and feedback!</p>
<ul>
<li>Added performance graphs to profile page. Clicking on a number in the table will now display a graph showing historical performance vs global metrics for that encounter / archetype combination</li>
Expand Down
18 changes: 12 additions & 6 deletions raidar/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def _safe_get(f, default=None):
except (KeyError, TypeError):
return default

def _error(msg, **kwargs):
def _error(msg, status=200, **kwargs):
kwargs['error'] = str(msg)
return JsonResponse(kwargs)
return JsonResponse(kwargs, status=status)


def _userprops(request):
Expand Down Expand Up @@ -373,6 +373,7 @@ def initial(request):
return JsonResponse(response)


@sensitive_variables('password')
def _perform_login(request):
username = request.POST.get('username')
password = request.POST.get('password')
Expand All @@ -387,7 +388,6 @@ def _perform_login(request):

@require_POST
@sensitive_post_parameters('password')
@sensitive_variables('password')
def login(request):
if request.method == 'GET':
return index(request, page={ 'name': 'login' })
Expand Down Expand Up @@ -480,10 +480,13 @@ def logout(request):

def _perform_upload(request):
if (len(request.FILES) != 1):
return _error("Only single file uploads are allowed")
return ("Only single file uploads are allowed", None)

filename = next(iter(request.FILES))
file = request.FILES['file']
if 'file' in request.FILES:
file = request.FILES['file']
else:
return ("Missing file attachment named `file`", None)
filename = file.name
uploaded_at = time()

Expand Down Expand Up @@ -511,12 +514,15 @@ def upload(request):

@csrf_exempt
@require_POST
@sensitive_post_parameters('password')
def api_upload(request):
user = _perform_login(request)
if not user:
return _error('Could not authenticate')
return _error('Could not authenticate', status=401)
auth_login(request, user)
filename, upload = _perform_upload(request)
if not upload:
return _error(filename, status=400)

return JsonResponse({"filename": filename, "upload_id": upload.id})

Expand Down

0 comments on commit 184732f

Please sign in to comment.