<commit_before>time = require 'time'

before ->
    Alarm.find req.params.id, (err, alarm) =>
        if err or not alarm
            send error: true, msg: "Alarm not found", 404
        else
            @alarm = alarm
            next()
# Make this pre-treatment only before update and delete action.
, only: ['getOne', 'update', 'delete']

before ->

    @convertAlarmDate = (alarm, timezone) ->
        timezonedDate = new time.Date(alarm.trigg)
        timezonedDate.setTimezone(timezone)
        alarm.trigg = timezonedDate.toString().slice(0, 24)
        return alarm

    @userTimezone = 'Europe/Paris'
    User.all (err, users) =>
        if err
            console.log err
        else if users.length == 0
            console.log 'No user registered.'
        else
            @userTimezone = users[0].timezone

        next()


, except: ['delete']

action 'all', ->

    Alarm.all (err, alarms) =>
        if err
            send error: true, msg: 'Server error occurred while retrieving data'
        else
            for alarm, index in alarms
                alarms[index] = @convertAlarmDate(alarm, @userTimezone)
            send alarms<commit_msg>Better coffee syntax<commit_after>time = require 'time'

before ->
    Alarm.find req.params.id, (err, alarm) =>
        if err or not alarm
            send error: true, msg: "Alarm not found", 404
        else
            @alarm = alarm
            next()
# Make this pre-treatment only before update and delete action.
, only: ['getOne', 'update', 'delete']

before ->

    @convertAlarmDate = (alarm, timezone) ->
        timezonedDate = new time.Date(alarm.trigg)
        timezonedDate.setTimezone(timezone)
        alarm.trigg = timezonedDate.toString().slice(0, 24)
        return alarm

    @userTimezone = 'Europe/Paris'
    User.all (err, users) =>
        if err
            console.log err
        else if users.length is 0
            console.log 'No user registered.'
        else
            @userTimezone = users[0].timezone

        next()


, except: ['delete']

action 'all', ->

    Alarm.all (err, alarms) =>
        if err
            send error: true, msg: 'Server error occurred while retrieving data'
        else
            for alarm, index in alarms
                alarms[index] = @convertAlarmDate(alarm, @userTimezone)
            send alarms
{'fraction_non_alphanumeric': 0.10602821718683197, 'fraction_numerical': 0.006840530141085934, 'mean_word_length': 1.9733163913595935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4878646', 'n_tokens_mistral': 710, 'n_tokens_neox': 672, 'n_words': 206}