Skip to content

Fbxcall#17

Open
afer92 wants to merge 7 commits intoskimpax:masterfrom
afer92:fbxcall
Open

Fbxcall#17
afer92 wants to merge 7 commits intoskimpax:masterfrom
afer92:fbxcall

Conversation

@afer92
Copy link
Contributor

@afer92 afer92 commented Mar 27, 2019

Add class FbxCall with properties and sql query helper. Setter for new property.
Add class FbxCalls with get_by_id

fbxosctrl.py Outdated
str_replace = u'REPLACE' if replace else u'INSERT'
fields = u'`id`, `type`, `datetime`, `number`, `name`, `duration`, `new`, `contact_id`,`src`'
query = "%s INTO {} (%s) " % (str_replace, fields)
print(query)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To delete

@skimpax
Copy link
Owner

skimpax commented Mar 28, 2019

It is not clear to me the use case for FbxCall: it is never called anywhere.
Can you describe it? (in French if you prefer).

@afer92
Copy link
Contributor Author

afer92 commented Mar 28, 2019

It is not clear to me the use case for FbxCall: it is never called anywhere.
Can you describe it? (in French if you prefer).

J'utilise fbxosctrl comme module. Je n'ai pas voulu modifier votre class FbxServiceCall, je fait une classe fille :
class MyFbxServiceCall(FbxServiceCall):
"""Call domain"""

def __init__(self, http, conf):
    super().__init__(http, conf)
    self._calls = FbxCalls()
    resp = self.get_service_data('/call/log/')
    calls = resp.result
    for call in calls:
        self._calls.append(FbxCall(self, call))

def _get_calls_list(self, new_only):
    """ List the calls """
    log(">>> get_calls_list")
    calls = []
    for call in self._calls.calls:
        if new_only is False:
            calls.append(call)
        elif call.new:
            calls.append(call)
    return calls

@property
def calls(self):
    return self._calls

J'utilise la classe fille pour mettre à jour une base MySql, d'où les propriétés sql_replace ou sql_insert.
La classe FbxCall permet également de mettre à jour la propriété "new" sur un seul appel. Ce peut être utilisé pour marquer les appels écrits en base de données.
J'ai la même démarche avec la branche predir pour mettre à jour les redirections, que j'utilise pour les renouvellements letsencrypt.

@afer92
Copy link
Contributor Author

afer92 commented Mar 28, 2019

It is not clear to me the use case for FbxCall: it is never called anywhere.
Can you describe it? (in French if you prefer).

for call in srv_call.calls:
    count += 1
    log(call)
    log('#{}#{}#{}# {} {} {} {} {}'.format(count,
          call.strnew, call.id, call.sqldate,
          call.tag, call.number, call.naming, call.strdur))
    query = call.sql_replace.format(u'`FREEBOX`.`calls`')
    db_update(query)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants