Commit 582a94ee authored by Jeremy Pallats's avatar Jeremy Pallats 💬
Browse files

FIX #78: Make edmc filter by age.

- New cutoff allows selecting the min age to consider candidate for
  scout.
parent 3455644a
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -559,7 +559,7 @@ class BGS(Action):
        resp += "\n".join(controls)

        control_ages = await self.bot.loop.run_in_executor(None, cogdb.side.get_system_ages,
                                                           kwargs['side_session'], controls)
                                                           kwargs['side_session'], controls, self.args.age)
        for control_name in control_ages:
            resp += "\n\n__{}__\n".format(string.capwords(control_name))
            ages = control_ages[control_name]
+3 −0
Original line number Diff line number Diff line
@@ -144,6 +144,8 @@ def subs_bgs(subs, prefix):
        Present the optimized route to jump and update EDMC for default systems.
**{prefix}bgs edmc Rana, Frey**
        Present the optimized route to jump and update EDMC for Rana, Frey.
**{prefix}bgs edmc --age 2 Rana, Frey**
        Present the optimized route to jump and update EDMC for Rana, Frey.
**{prefix}bgs exp Rana**
        Show all factions in Rana, select one, then show all expansion candidates.
**{prefix}bgs expto Rana**
@@ -172,6 +174,7 @@ def subs_bgs(subs, prefix):
    subcmd = subcmds.add_parser('dash', help='Dashboard overview of exploiteds around a control.')
    subcmd.add_argument('system', nargs='+', help='The system to lookup.')
    subcmd = subcmds.add_parser('edmc', help='Create the EDMC update route.')
    subcmd.add_argument('--age', type=int, default=1, help='The results will be this old or more.')
    subcmd.add_argument('system', nargs='*', help='The control systems to update.')
    subcmd = subcmds.add_parser('exp', help='Find expansion candidates from system.')
    subcmd.add_argument('system', nargs='+', help='The system to lookup.')
+3 −2
Original line number Diff line number Diff line
@@ -1230,7 +1230,7 @@ def monitor_factions(session, faction_names=None):


@wrap_exceptions
def get_system_ages(session, controls):
def get_system_ages(session, controls, cutoff=1):
    """
    Get the list of Systems that have stale EDDN data.

@@ -1238,7 +1238,8 @@ def get_system_ages(session, controls):
        {'control': [system, system], ...}
    """
    ages = session.query(SystemAge).\
        filter(SystemAge.control.in_(controls)).\
        filter(SystemAge.control.in_(controls),
               SystemAge.age >= cutoff).\
        all()

    map_ages = {x: [] for x in controls}